@@ -8,11 +8,18 @@ const editor = CodeMirror(document.getElementById('div-1'), {
88 autoCloseBrackets : true
99} ) ;
1010
11- //run first cell on double click
12- $ ( `#div-1` ) . dblclick ( function ( ) {
13- exec_cell ( `run_div-1` ) ;
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+ }
1419} ) ;
1520
21+
22+
1623var md = new Remarkable ( )
1724//Global Params
1825let vars_in_scope = {
@@ -59,7 +66,12 @@ function exec_cell(c_id) {
5966 }
6067 }
6168
62- $ ( `#out_${ id } ` ) . html ( output ) ;
69+ Promise . resolve ( output ) . then ( ( val ) => {
70+ $ ( `#out_${ id } ` ) . html ( val ) ;
71+ document . getElementById ( "cell_spinner-1" ) . style . display = "none"
72+ document . getElementById ( "cell_num-1" ) . style . display = "block"
73+ } )
74+
6375
6476 count = parseInt ( count ) + 1
6577 let div_count = `div-${ count } `
@@ -159,9 +171,14 @@ function add_new_code_cell(c_id, where) {
159171 } ) ;
160172
161173
162- //run cell on double click
163- $ ( `#div-${ new_id } ` ) . dblclick ( function ( ) {
164- exec_cell ( `run_div-${ new_id } ` ) ;
174+ //run cell on CTRL-ENTER Pressed
175+ $ ( `#div-${ new_id } ` ) . keydown ( function ( e ) {
176+ if ( ( e . ctrlKey || e . metaKey ) && ( e . keyCode == 13 || e . keyCode == 10 ) ) {
177+ document . getElementById ( "cell_spinner-1" ) . style . display = "block"
178+ document . getElementById ( "cell_num-1" ) . style . display = "none"
179+ exec_cell ( `run_div-${ new_id } ` ) ;
180+
181+ }
165182 } ) ;
166183
167184}
@@ -245,7 +262,6 @@ function add_new_text_cell(c_id, where) {
245262 document . getElementById ( `btn-actions-${ new_id } ` ) . style . display = "none"
246263 } ) ;
247264
248-
249265}
250266
251267function delete_cell ( id ) {
@@ -262,13 +278,13 @@ function delete_cell(id) {
262278
263279
264280$ ( document ) . on ( "click" , "button.run" , function ( ) {
265- console . log ( this . id ) ;
266-
267281 if ( this . id . split ( "_" ) . includes ( "md" ) ) {
268282 let id = this . id . split ( "-" ) [ 1 ]
269283 let val = document . getElementById ( `text-box_${ id } ` ) . value
270284 show_md ( id , val )
271285 } else {
286+ document . getElementById ( "cell_spinner-1" ) . style . display = "block"
287+ document . getElementById ( "cell_num-1" ) . style . display = "none"
272288 exec_cell ( this . id ) ;
273289 }
274290} )
@@ -315,6 +331,7 @@ function show_md(id, value) {
315331 document . getElementById ( div_id ) . style . display = "none"
316332}
317333
334+
318335$ ( document ) . on ( "dblclick" , "div.text-out-box" , function ( ) {
319336 let id = this . id . split ( "_" ) [ 1 ]
320337 md_id = `text-div_${ id } `
0 commit comments