Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
tianyazhichiC
algorithm-visualizer
提交
11522de3
A
algorithm-visualizer
项目概览
tianyazhichiC
/
algorithm-visualizer
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
algorithm-visualizer
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
11522de3
编写于
5月 28, 2016
作者:
D
duaraghav8@gmail
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'upstream/gh-pages' into gh-pages
上级
dcf8acf0
6c90c7ca
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
21 deletion
+36
-21
js/script.js
js/script.js
+36
-21
未找到文件。
js/script.js
浏览文件 @
11522de3
...
...
@@ -158,15 +158,10 @@ var executeDataAndCode = function () {
}
$
(
'
.sidemenu button
'
).
removeClass
(
'
active
'
);
$menu
.
addClass
(
'
active
'
);
var
requestedTab
=
getHashValue
(
'
tab
'
);
if
(
requestedTab
)
{
if
(
requestedTab
===
'
trace
'
)
$
(
'
#btn_trace
'
).
click
();
else
$
(
'
#btn_desc
'
).
click
();
}
else
{
$
(
'
#btn_desc
'
).
click
();
}
var
requestedTab
=
getAlgorithmHash
(
'
algorithm
'
)[
'
tab
'
];
if
(
requestedTab
===
'
trace
'
)
$
(
'
#btn_trace
'
).
click
();
else
$
(
'
#btn_desc
'
).
click
();
$
(
'
#category
'
).
html
(
category_name
);
$
(
'
#algorithm
'
).
html
(
algorithm_name
);
...
...
@@ -257,12 +252,16 @@ var executeDataAndCode = function () {
showDescription
(
data
);
showFiles
(
category
,
algorithm
,
files
);
});
var
hash
=
isScratchPaper
(
category
,
algorithm
)
?
algorithm
:
category
+
'
/
'
+
algorithm
;
setHashValue
(
'
algorithm
'
,
hash
);
};
var
list
=
{};
var
anyOpened
=
false
;
$
.
getJSON
(
'
./algorithm/category.json
'
,
function
(
data
)
{
var
requestedCategory
=
getHashValue
(
'
category
'
),
requestedAlgorithm
=
getHashValue
(
'
algorithm
'
);
var
algorithmHash
=
getAlgorithmHash
();
console
.
log
(
algorithmHash
);
var
requestedCategory
=
algorithmHash
[
'
category
'
],
requestedAlgorithm
=
algorithmHash
[
'
algorithm
'
];
var
anyRequested
=
requestedCategory
&&
requestedAlgorithm
;
anyOpened
=
anyRequested
;
...
...
@@ -285,9 +284,6 @@ var executeDataAndCode = function () {
.
attr
(
'
data-algorithm
'
,
algorithm
)
.
attr
(
'
data-category
'
,
category
)
.
click
(
function
()
{
setHashValue
(
'
category
'
,
category
);
setHashValue
(
'
algorithm
'
,
algorithm
);
setHashValue
(
'
tab
'
,
'
desc
'
);
loadAlgorithm
(
category
,
algorithm
);
});
$
(
'
#list
'
).
append
(
$algorithm
);
...
...
@@ -304,9 +300,6 @@ var executeDataAndCode = function () {
if
(
!
list
[
requestedCategory
]
||
!
list
[
requestedCategory
].
list
[
requestedAlgorithm
])
{
showErrorToast
(
'
Oops! This link appears to be broken.
'
);
$
(
'
#scratch-paper
'
).
click
();
removeHashValue
(
'
category
'
);
removeHashValue
(
'
algorithm
'
);
removeHashValue
(
'
tab
'
);
}
else
{
$
(
'
[data-category="
'
+
requestedCategory
+
'
"]
'
).
toggleClass
(
'
collapse
'
);
loadAlgorithm
(
requestedCategory
,
requestedAlgorithm
);
...
...
@@ -363,6 +356,7 @@ var executeDataAndCode = function () {
$
(
'
#btn_share
'
).
click
(
function
()
{
var
$icon
=
$
(
this
).
find
(
'
.fa-share
'
);
$icon
.
addClass
(
'
fa-spin fa-spin-faster
'
);
shareScratchPaper
(
function
(
url
)
{
$icon
.
removeClass
(
'
fa-spin fa-spin-faster
'
);
$
(
'
#shared
'
).
removeClass
(
'
collapse
'
);
...
...
@@ -401,14 +395,16 @@ var executeDataAndCode = function () {
$
(
'
#tab_desc
'
).
addClass
(
'
active
'
);
$
(
'
.tab_bar > button
'
).
removeClass
(
'
active
'
);
$
(
this
).
addClass
(
'
active
'
);
setHashValue
(
'
tab
'
,
'
desc
'
);
var
algorithmHash
=
getAlgorithmHash
();
setHashValue
(
'
algorithm
'
,
algorithmHash
[
'
category
'
]
+
'
/
'
+
algorithmHash
[
'
algorithm
'
]);
});
$
(
'
#btn_trace
'
).
click
(
function
()
{
$
(
'
.tab_container > .tab
'
).
removeClass
(
'
active
'
);
$
(
'
#tab_module
'
).
addClass
(
'
active
'
);
$
(
'
.tab_bar > button
'
).
removeClass
(
'
active
'
);
$
(
this
).
addClass
(
'
active
'
);
setHashValue
(
'
tab
'
,
'
trace
'
);
var
algorithmHash
=
getAlgorithmHash
();
setHashValue
(
'
algorithm
'
,
algorithmHash
[
'
category
'
]
+
'
/
'
+
algorithmHash
[
'
algorithm
'
]
+
'
/trace
'
);
});
$
(
window
).
resize
(
function
()
{
...
...
@@ -519,6 +515,7 @@ var executeDataAndCode = function () {
}
return
null
;
}
var
setHashValue
=
function
(
key
,
value
)
{
if
(
!
key
||
!
value
)
return
;
var
hash
=
window
.
location
.
hash
.
substr
(
1
);
...
...
@@ -540,6 +537,7 @@ var executeDataAndCode = function () {
var
newHash
=
params
.
join
(
'
&
'
);
window
.
location
.
hash
=
'
#
'
+
newHash
;
}
var
removeHashValue
=
function
(
key
)
{
if
(
!
key
)
return
;
var
hash
=
window
.
location
.
hash
.
substr
(
1
);
...
...
@@ -556,6 +554,23 @@ var executeDataAndCode = function () {
var
newHash
=
params
.
join
(
'
&
'
);
window
.
location
.
hash
=
'
#
'
+
newHash
;
}
var
getAlgorithmHash
=
function
()
{
var
hash
=
getHashValue
(
'
algorithm
'
);
if
(
hash
){
var
regex
=
/
(?:[^\/\\]
+|
\\
.
)
+/g
;
var
tmp
=
null
,
algorithmHash
=
{},
i
=
0
;
while
(
tmp
=
regex
.
exec
(
hash
)){
if
(
i
===
0
)
algorithmHash
[
'
category
'
]
=
tmp
[
0
];
if
(
i
===
1
)
algorithmHash
[
'
algorithm
'
]
=
tmp
[
0
];
if
(
i
===
2
)
algorithmHash
[
'
tab
'
]
=
tmp
[
0
];
i
++
;
}
return
algorithmHash
;
}
else
return
false
;
}
// Share scratch paper
var
getParameterByName
=
function
(
name
)
{
...
...
@@ -579,7 +594,7 @@ var executeDataAndCode = function () {
};
$
.
post
(
'
https://api.github.com/gists
'
,
JSON
.
stringify
(
gist
),
function
(
res
)
{
var
data
=
JSON
.
parse
(
res
);
if
(
callback
)
callback
(
location
.
protocol
+
'
//
'
+
location
.
host
+
location
.
pathname
+
'
?
scratch-paper=
'
+
data
.
id
);
if
(
callback
)
callback
(
location
.
protocol
+
'
//
'
+
location
.
host
+
location
.
pathname
+
'
#
scratch-paper=
'
+
data
.
id
);
});
};
...
...
@@ -599,7 +614,7 @@ var executeDataAndCode = function () {
});
};
var
gistID
=
get
ParameterByNam
e
(
'
scratch-paper
'
);
var
gistID
=
get
HashValu
e
(
'
scratch-paper
'
);
if
(
gistID
)
{
loadScratchPaper
(
gistID
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录