Skip to content

Commit 8fc66a5

Browse files
committed
make small changes
1 parent d8935ab commit 8fc66a5

1 file changed

Lines changed: 7 additions & 40 deletions

File tree

  • notebookjs/src/public/javascripts

notebookjs/src/public/javascripts/index.js

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,6 @@ const editor = CodeMirror(document.getElementById('div-1'), {
88
autoCloseBrackets: true
99
});
1010

11-
//run first cell on CTRL ENTER Pressed
12-
$(`#div-1`).keydown(function (e) {
13-
if ((e.ctrlKey || e.metaKey) && (e.keyCode == 13 || e.keyCode == 10)) {
14-
document.getElementById("cell_spinner-1").style.display = "block"
15-
document.getElementById("cell_num-1").style.display = "none"
16-
exec_cell(`run_div-1`);
17-
18-
}
19-
});
20-
21-
2211

2312
var md = new Remarkable()
2413
//Global Params
@@ -50,12 +39,11 @@ function exec_cell(c_id) {
5039
let output = ("global", eval)(vars_in_scope[id].getValue())
5140
if (Array.isArray(output)) {
5241
output = print_val(output)
53-
} else if (typeof output == 'object' && output !== null) {
42+
}
43+
else if (typeof output === 'object' && output !== null) {
5444
output = JSON.stringify(output)
55-
if (output == "{}") {
56-
output = ""
57-
}
58-
} else if (console) {
45+
}
46+
else if (console) {
5947
//retreive value from the console funcction
6048
console.oldLog = console.log;
6149
console.log = function (value) {
@@ -73,8 +61,6 @@ function exec_cell(c_id) {
7361
}
7462

7563
$(`#out_${id}`).html(output);
76-
document.getElementById("cell_spinner-1").style.display = "none"
77-
document.getElementById("cell_num-1").style.display = "block"
7864

7965
count = parseInt(count) + 1
8066
let div_count = `div-${count}`
@@ -83,8 +69,6 @@ function exec_cell(c_id) {
8369
} catch (error) {
8470
$(`#out_${id}`).html(error)
8571
console.log(error)
86-
document.getElementById("cell_spinner-1").style.display = "none"
87-
document.getElementById("cell_num-1").style.display = "block"
8872

8973
}
9074
}
@@ -157,16 +141,13 @@ function add_new_code_cell(c_id, where) {
157141

158142
let editor = CodeMirror(document.getElementById(`div-${new_id}`), {
159143
lineNumbers: true,
160-
tabSize: 4,
144+
tabSize: 2,
161145
mode: 'javascript',
162146
theme: 'monokai',
163-
value: '',
164-
extraKeys: { "Ctrl-Space": "autocomplete" },
165-
autoCloseBrackets: true
147+
value: ''
166148
});
167149
vars_in_scope[`div-${new_id}`] = editor
168150

169-
//show action buttons on hover
170151
$(`#div-${new_id}`)
171152
.mouseover(function () {
172153
$(`#btn-actions-${new_id}`).show()
@@ -175,17 +156,6 @@ function add_new_code_cell(c_id, where) {
175156
$(`#btn-actions-${new_id}`).hide()
176157
});
177158

178-
179-
//run cell on CTRL-ENTER Pressed
180-
$(`#div-${new_id}`).keydown(function (e) {
181-
if ((e.ctrlKey || e.metaKey) && (e.keyCode == 13 || e.keyCode == 10)) {
182-
document.getElementById("cell_spinner-1").style.display = "block"
183-
document.getElementById("cell_num-1").style.display = "none"
184-
exec_cell(`run_div-${new_id}`);
185-
186-
}
187-
});
188-
189159
}
190160

191161
function add_new_text_cell(c_id, where) {
@@ -267,6 +237,7 @@ function add_new_text_cell(c_id, where) {
267237
document.getElementById(`btn-actions-${new_id}`).style.display = "none"
268238
});
269239

240+
270241
}
271242

272243
function delete_cell(id) {
@@ -289,13 +260,10 @@ $(document).on("click", "button.run", function () {
289260
let val = document.getElementById(`text-box_${id}`).value
290261
show_md(id, val)
291262
} else {
292-
document.getElementById("cell_spinner-1").style.display = "block"
293-
document.getElementById("cell_num-1").style.display = "none"
294263
exec_cell(this.id);
295264
}
296265
})
297266

298-
299267
$(document).on("click", "button.del", function () {
300268
let id = this.id.split("_")[1]
301269
console.log(id,this.id, __code_cell_count)
@@ -338,7 +306,6 @@ function show_md(id, value) {
338306
document.getElementById(div_id).style.display = "none"
339307
}
340308

341-
342309
$(document).on("dblclick", "div.text-out-box", function () {
343310
let id = this.id.split("_")[1]
344311
md_id = `text-div_${id}`

0 commit comments

Comments
 (0)