File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,7 +13,13 @@ let vars_in_scope = {
1313}
1414
1515function exec_cell ( id , count ) {
16- $ ( `#out_${ id } ` ) . html ( ( "global" , eval ) ( vars_in_scope [ id ] . getValue ( ) ) || "" ) ;
16+
17+ let global_scope = ( "global" , eval ) ( vars_in_scope [ id ] . getValue ( ) )
18+
19+ if ( Array . isArray ( global_scope ) ) {
20+ global_scope = print_val ( global_scope )
21+ }
22+ $ ( `#out_${ id } ` ) . html ( global_scope || "" ) ;
1723
1824 count = parseInt ( count ) + 1
1925 let div_count = `div-${ count } `
Original file line number Diff line number Diff line change 1+ function print_val ( val ) {
2+
3+ if ( Array . isArray ( val [ 0 ] ) ) {
4+
5+ let col_length = val [ 0 ] . length ;
6+ let row_length = val . length ;
7+
8+ let data_string = "[" ;
9+ if ( row_length > 10 ) {
10+
11+ for ( let i = 0 ; i < 10 ; i ++ ) {
12+
13+ let row_val = val [ i ]
14+
15+ data_string += "[" ;
16+ if ( col_length > 10 ) {
17+
18+ for ( let j = 0 ; j < 10 ; j ++ ) {
19+ data_string += `${ row_val [ j ] } ,`
20+ }
21+
22+ data_string += `.......${ col_length - 10 } more],`
23+ } else {
24+
25+ for ( let j = 0 ; j < col_length ; j ++ ) {
26+ data_string += `${ row_val [ j ] } ,`
27+ }
28+ data_string += "],"
29+ }
30+ }
31+ data_string += `...${ row_length - 10 } more]`
32+ }
33+ else {
34+ for ( let i = 0 ; i < row_length ; i ++ ) {
35+
36+ let row_val = val [ i ]
37+
38+ data_string += "[" ;
39+ if ( col_length > 10 ) {
40+
41+ for ( let j = 0 ; j < 10 ; j ++ ) {
42+ data_string += `${ row_val [ j ] } ,`
43+ }
44+
45+ data_string += `.......${ col_length - 10 } more],`
46+ } else {
47+
48+ for ( let j = 0 ; j < col_length ; j ++ ) {
49+ data_string += `${ row_val [ j ] } ,`
50+ }
51+ data_string += "],"
52+ }
53+ }
54+ data_string += "]"
55+ }
56+ return data_string
57+ } else {
58+
59+ let row_length = val . length ;
60+
61+ let data_string = "["
62+
63+ let count = row_length > 10 ? 10 : row_length
64+
65+ for ( let i = 0 ; i < count ; i ++ ) {
66+
67+ data_string += `${ val [ i ] } ,`
68+ }
69+
70+ let diff = row_length - count ;
71+ if ( diff > 0 ) {
72+ data_string += `....${ diff } more]`
73+ } else {
74+ data_string += "]" ;
75+ }
76+ return data_string ;
77+
78+ }
79+ }
Original file line number Diff line number Diff line change 6969
7070
7171<script src =" javascripts/index.js" ></script >
72+ <script src =" javascripts/utils.js" ></script >
7273</body >
7374
7475</html >
You can’t perform that action at this time.
0 commit comments