@@ -43,49 +43,47 @@ $("#div-1")
4343
4444
4545function exec_cell ( c_id ) {
46+ $ ( `#out_${ id } ` ) . html ( "" )
4647 let id = c_id . split ( "_" ) [ 1 ]
4748 let count = c_id . split ( "-" ) [ 1 ]
4849 window . current_cell = id ;
4950
5051 try {
51- let command = vars_in_scope [ id ] . getValue ( )
52- if ( command . includes ( "console.log(" ) || command . includes ( "table" ) || command . includes ( "plot" ) ) {
53- let output = ( "global" , eval ) ( vars_in_scope [ id ] . getValue ( ) )
52+ let output = ( "global" , eval ) ( vars_in_scope [ id ] . getValue ( ) )
53+ if ( Array . isArray ( output ) ) {
54+ output = print_val ( output )
55+ } else if ( typeof output === 'object' && output !== null ) {
56+ output = JSON . stringify ( output )
57+ if ( output == "{}" ) {
58+ output = ""
59+ }
60+ } else if ( console ) {
61+ //retreive value from the console funcction
62+ console . oldLog = console . log ;
63+ console . log = function ( value ) {
64+ return value ;
65+ } ;
66+ output = eval ( vars_in_scope [ id ] . getValue ( ) ) ;
67+
5468 if ( Array . isArray ( output ) ) {
5569 output = print_val ( output )
56- } else if ( typeof output === 'object' && output !== null ) {
57- output = JSON . stringify ( output )
58- if ( output == "{}" ) {
59- output = ""
60- }
61- } else if ( console ) {
62- //retreive value from the console funcction
63- console . oldLog = console . log ;
64- console . log = function ( value ) {
65- return value ;
66- } ;
67- output = eval ( vars_in_scope [ id ] . getValue ( ) ) ;
68-
69- if ( Array . isArray ( output ) ) {
70- output = print_val ( output )
71- } else {
72- if ( typeof output === 'object' && output !== null ) {
73- output = JSON . stringify ( output )
74- if ( output == "{}" ) {
75- output = ""
76- }
70+ } else {
71+ if ( typeof output === 'object' && output !== null ) {
72+ output = JSON . stringify ( output )
73+ if ( output == "{}" ) {
74+ output = ""
7775 }
78-
7976 }
80- $ ( `#out_${ id } ` ) . html ( "" ) ;
81- $ ( `#out_${ id } ` ) . html ( output ) ;
77+
8278 }
83- } else {
84- ( "global" , eval ) ( command )
85- $ ( `#out_${ id } ` ) . html ( "" ) ;
8679 }
8780
88- // $(`#out_${id}`).html(output);
81+ // $(`#out_${id}`).empty()
82+ let command = vars_in_scope [ id ] . getValue ( )
83+ if ( command . includes ( "table" ) || command . includes ( "plot" ) || command . includes ( "console.log(" ) ) {
84+ // $(`#out_${id}`).html("")
85+ $ ( `#out_${ id } ` ) . html ( output ) ;
86+ }
8987 // document.getElementById("cell_spinner-1").style.display = "none"
9088 // document.getElementById("cell_num-1").style.display = "block"
9189
@@ -94,7 +92,7 @@ function exec_cell(c_id) {
9492 window . current_cell = div_count
9593
9694 } catch ( error ) {
97- $ ( `#out_${ id } ` ) . html ( "" ) ;
95+ $ ( `#out_${ id } ` ) . html ( "" )
9896 $ ( `#out_${ id } ` ) . html ( error )
9997 console . log ( error )
10098 // document.getElementById("cell_spinner-1").style.display = "none"
0 commit comments