Skip to content

Commit 9c620d8

Browse files
committed
create a simple prototype with index.html
1 parent 582d0fa commit 9c620d8

3 files changed

Lines changed: 196 additions & 1 deletion

File tree

notebookjs/src/routes/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var router = express.Router();
33

44
/* GET home page. */
55
router.get('/', function(req, res, next) {
6-
res.render('index', { title: 'Express' });
6+
res.render('index2', { title: 'Express' });
77
});
88

99
module.exports = router;

notebookjs/src/views/index.html

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/codemirror.min.css">
8+
</link>
9+
<script type="text/javascript"
10+
src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/codemirror.min.js"></script>
11+
<script type="text/javascript"
12+
src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/mode/javascript/javascript.min.js"></script>
13+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/theme/monokai.min.css">
14+
<script src="https://cdn.jsdelivr.net/npm/danfojs@0.1.1/dist/index.min.js"></script>
15+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
16+
17+
<title>Document</title>
18+
</head>
19+
20+
<body>
21+
<div id="container">
22+
23+
<div id="div-1" style="width:100%;height:30%;">
24+
25+
</div>
26+
<button style="color: black;" id="run_div-1" class="run">Run</button>
27+
<div id=out_div-1></div>
28+
29+
30+
31+
32+
</div>
33+
34+
35+
36+
<script>
37+
const editor = CodeMirror(document.getElementById('div-1'), {
38+
lineNumbers: true,
39+
tabSize: 2,
40+
mode: 'javascript',
41+
theme: 'monokai',
42+
value: ''
43+
});
44+
45+
/////PROTO///////////
46+
47+
let store_cope = {
48+
"div-1": editor
49+
}
50+
51+
function exec_cell(id,count){
52+
53+
$(`#out_${id}`).html(("global", eval)(store_cope[id].getValue()) || "");
54+
55+
count = parseInt(count) +1
56+
let div_count = `div-${count}`
57+
58+
if(!(div_count in store_cope)){
59+
$("#container").append(
60+
`<div id=${div_count} class=""></div><br />
61+
<button style="color: black;" id=run_${div_count} class="run">Run</button>
62+
<div id=out_${div_count}></div><br />`
63+
)
64+
65+
let editor = CodeMirror(document.getElementById(`${div_count}`), {
66+
lineNumbers: true,
67+
tabSize: 2,
68+
mode: 'javascript',
69+
theme: 'monokai',
70+
value: ''
71+
});
72+
73+
74+
store_cope[div_count] = editor;
75+
76+
}
77+
78+
}
79+
80+
$(document).on("click","button.run",function(){
81+
let id = this.id.split("_")[1]
82+
let count = this.id.split("-")[1]
83+
exec_cell(id,count);
84+
})
85+
</script>
86+
87+
88+
89+
90+
91+
</body>
92+
93+
</html>
94+
95+
96+
97+
98+
<!-- async function load(){
99+
df = await dfd.read_csv("https://raw.githubusercontent.com/pandas-dev/pandas/master/doc/data/titanic.csv")
100+
return df
101+
102+
}
103+
104+
df = load().then((df)=>{return df}) -->

notebookjs/src/views/index2.hbs

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/codemirror.min.css">
8+
</link>
9+
<script type="text/javascript"
10+
src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/codemirror.min.js"></script>
11+
<script type="text/javascript"
12+
src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/mode/javascript/javascript.min.js"></script>
13+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/theme/monokai.min.css">
14+
<script src="https://cdn.jsdelivr.net/npm/danfojs@0.1.1/dist/index.min.js"></script>
15+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" ></script>
16+
17+
<title>Document</title>
18+
</head>
19+
20+
<body>
21+
<div>
22+
23+
<div id="my-div" style="width:100%;height:30%;">
24+
25+
</div>
26+
<button style="color: black;" id="run" onclick="run_cell(1)">Run</button>
27+
<div id="out" style="height: 500px; width: 1000px;">
28+
29+
</div>
30+
31+
32+
</div>
33+
34+
35+
36+
<script>
37+
var code_out, code_out2;
38+
var variable_space = {}
39+
40+
const editor = CodeMirror(document.getElementById('my-div'), {
41+
lineNumbers: true,
42+
tabSize: 2,
43+
mode: 'javascript',
44+
theme: 'monokai',
45+
value: ''
46+
});
47+
48+
//editor.on('changes', () => {
49+
// code_out = editor.getValue();
50+
// });
51+
52+
53+
console.log($('#my-div').val())
54+
55+
{{!-- function run_cell(id) {
56+
if (id == 1) {
57+
console.log(code_out);
58+
let a = ("global", eval)(code_out)
59+
// a = eval(code_out) + "<br>"
60+
document.getElementById("out").innerHTML = a
61+
62+
} else {
63+
// console.log(variable_space[code_out2]);
64+
// a = eval(code_out2) + "<br>"
65+
console.log(code_out);
66+
document.getElementById("out2").innerHTML = ("global", eval)(code_out2)
67+
68+
}
69+
// var a = eval(code_out) + "<br>"
70+
// document.getElementById("out").innerHTML = a
71+
} --}}
72+
</script>
73+
74+
75+
76+
77+
78+
</body>
79+
80+
</html>
81+
82+
83+
84+
85+
<!-- async function load(){
86+
df = await dfd.read_csv("https://raw.githubusercontent.com/pandas-dev/pandas/master/doc/data/titanic.csv")
87+
return df
88+
89+
}
90+
91+
df = load().then((df)=>{return df}) -->

0 commit comments

Comments
 (0)