Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
tianyazhichiC
algorithm-visualizer
提交
f9eb7c25
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f9eb7c25
编写于
7月 01, 2016
作者:
K
Kevin Nadro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
progress on generating javascript code
got the logger to print the javascript code now
上级
3b2ec688
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
41 addition
and
13 deletion
+41
-13
css/stylesheet.css
css/stylesheet.css
+1
-0
index.html
index.html
+6
-0
js/create/index.js
js/create/index.js
+34
-7
js/create/sb.js
js/create/sb.js
+0
-6
未找到文件。
css/stylesheet.css
浏览文件 @
f9eb7c25
...
@@ -676,4 +676,5 @@ input[type=number]::-webkit-outer-spin-button {
...
@@ -676,4 +676,5 @@ input[type=number]::-webkit-outer-spin-button {
.inputField
{
.inputField
{
width
:
16px
;
width
:
16px
;
border
:
0
;
}
}
index.html
浏览文件 @
f9eb7c25
...
@@ -139,8 +139,14 @@
...
@@ -139,8 +139,14 @@
<input
id=
"numColumns"
type=
"number"
value=
"5"
>
<input
id=
"numColumns"
type=
"number"
value=
"5"
>
</div>
</div>
<div>
Tracer Name:
<input
id=
"tracerName"
type=
"text"
value=
"default"
>
</div>
<div>
<div>
<button
id=
"button-2DMatrix"
>
Create 2DMatrix
</button>
<button
id=
"button-2DMatrix"
>
Create 2DMatrix
</button>
<button
id=
"button-generateJS"
>
Generate Javascript
</button>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
js/create/index.js
浏览文件 @
f9eb7c25
...
@@ -12,6 +12,10 @@ const getNumColumns = () => {
...
@@ -12,6 +12,10 @@ const getNumColumns = () => {
return
column_field
.
value
;
return
column_field
.
value
;
};
};
const
getTracerName
=
()
=>
{
return
document
.
getElementById
(
"
tracerName
"
).
value
;
}
const
fauxData
=
(
r
,
c
)
=>
{
const
fauxData
=
(
r
,
c
)
=>
{
var
arr
=
new
Array
(
r
);
var
arr
=
new
Array
(
r
);
for
(
var
i
=
0
;
i
<
c
;
i
++
)
{
for
(
var
i
=
0
;
i
<
c
;
i
++
)
{
...
@@ -46,21 +50,36 @@ const makeInputFields = () =>{
...
@@ -46,21 +50,36 @@ const makeInputFields = () =>{
};
};
const
generateJS
=
()
=>
{
const
generateJS
=
(
logger
)
=>
{
var
logger
=
new
modules
.
LogTracer
(
'
Generated Javascript
'
);
logger
.
clear
(
);
var
table
=
document
.
querySelector
(
'
.mtbl-table
'
);
var
table
=
document
.
querySelector
(
'
.mtbl-table
'
);
var
numRows
=
table
.
childNodes
.
length
;
var
numRows
=
table
.
childNodes
.
length
;
var
numColumns
=
table
.
childNodes
[
0
].
childNodes
.
length
;
var
numColumns
=
table
.
childNodes
[
0
].
childNodes
.
length
;
logger
.
print
(
'
Copy and paste this code in your data.js file!
'
);
logger
.
print
(
''
);
logger
.
print
(
'
let myTable = [
'
);
var
line
=
''
;
var
line
=
''
;
for
(
var
i
=
0
;
i
<
numRows
;
i
++
){
var
i
;
line
=
''
;
var
j
;
for
(
var
j
=
0
;
j
<
numColumns
;
j
++
){
var
comma
=
'
,
'
;
for
(
i
=
0
;
i
<
numRows
;
i
++
){
line
=
'
[
'
;
for
(
j
=
0
;
j
<
numColumns
-
1
;
j
++
){
line
+=
table
.
childNodes
[
i
].
childNodes
[
j
].
childNodes
[
0
].
value
+
'
,
'
;
line
+=
table
.
childNodes
[
i
].
childNodes
[
j
].
childNodes
[
0
].
value
+
'
,
'
;
}
}
if
(
i
===
numRows
-
1
){
comma
=
''
;}
line
+=
table
.
childNodes
[
i
].
childNodes
[
j
++
].
childNodes
[
0
].
value
+
'
]
'
+
comma
;
logger
.
print
(
line
);
logger
.
print
(
line
);
}
}
logger
.
print
(
'
]
'
);
logger
.
print
(
"
let myTableTracer = new Array2DTracer ('
"
+
getTracerName
()
+
"
')
"
);
logger
.
print
(
'
myTableTracer._setData (myTable)
'
);
};
};
...
@@ -86,16 +105,24 @@ const positionModules = () =>{
...
@@ -86,16 +105,24 @@ const positionModules = () =>{
const
setupButtons
=
()
=>
{
const
setupButtons
=
()
=>
{
var
button_2DMatrix
=
document
.
getElementById
(
"
button-2DMatrix
"
);
var
button_2DMatrix
=
document
.
getElementById
(
"
button-2DMatrix
"
);
var
logger
;
var
arr2DTracer
;
button_2DMatrix
.
addEventListener
(
'
click
'
,
function
(){
button_2DMatrix
.
addEventListener
(
'
click
'
,
function
(){
var
arr2DTracer
=
new
modules
.
Array2DTracer
();
arr2DTracer
=
new
modules
.
Array2DTracer
();
logger
=
new
modules
.
LogTracer
(
'
Generated Javascript
'
);
var
numRows
=
getNumRows
();
var
numRows
=
getNumRows
();
var
numColumns
=
getNumColumns
();
var
numColumns
=
getNumColumns
();
var
data
=
fauxData
(
numRows
,
numColumns
);
var
data
=
fauxData
(
numRows
,
numColumns
);
arr2DTracer
.
setData
(
data
);
arr2DTracer
.
setData
(
data
);
makeInputFields
();
makeInputFields
();
generateJS
();
positionModules
();
positionModules
();
arr2DTracer
.
refresh
();
},
false
);
var
button_JS
=
document
.
getElementById
(
'
button-generateJS
'
);
button_JS
.
addEventListener
(
'
click
'
,
function
(){
generateJS
(
logger
);
},
false
);
},
false
);
};
};
...
...
js/create/sb.js
已删除
100644 → 0
浏览文件 @
3b2ec688
'
use strict
'
;
module
.
exports
=
{
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录