Skip to content

Commit 9caa7e0

Browse files
committed
create plotting function
1 parent a424813 commit 9caa7e0

3 files changed

Lines changed: 44 additions & 15 deletions

File tree

notebookjs/src/public/javascripts/index.js

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ function exec_cell(c_id) {
6565
if (Array.isArray(output)) {
6666
output = print_val(output)
6767
} else {
68-
if(typeof output === 'object' && output !== null){
68+
if (typeof output === 'object' && output !== null) {
6969
output = JSON.stringify(output)
7070
}
71-
71+
7272
}
7373
}
7474

@@ -298,7 +298,7 @@ $(document).on("click", "button.run", function () {
298298

299299
$(document).on("click", "button.del", function () {
300300
let id = this.id.split("_")[1]
301-
console.log(id,this.id, __code_cell_count)
301+
console.log(id, this.id, __code_cell_count)
302302
delete_cell(id)
303303
})
304304

@@ -362,7 +362,7 @@ function update_text_box_size() {
362362

363363

364364
$("#download").click(function () {
365-
let out = notebook_json(vars_in_scope,md_texts);
365+
let out = notebook_json(vars_in_scope, md_texts);
366366

367367
var blob = new Blob([out], { "type": "application/json" });
368368
var url = (window.URL || window.webkitURL).createObjectURL(blob);
@@ -377,14 +377,16 @@ $("#download").click(function () {
377377
link_pae.remove();
378378
});
379379

380-
$("#uploadnb").click(function() {
380+
381+
382+
$("#import-notebook-file").change(() => {
381383

382384
var files = $("#import-notebook-file")[0].files
383385
let json_content = null
384-
if(files.length > 0){
386+
if (files.length > 0) {
385387
var content = files[0];
386388
var reader = new FileReader();
387-
reader.onload = function(t){
389+
reader.onload = function (t) {
388390
json_content = t.target.result;
389391
let json = JSON.parse(json_content)
390392

@@ -394,8 +396,28 @@ $("#uploadnb").click(function() {
394396
}
395397
reader.readAsText(content);
396398
}
399+
// $("#uploadNoteModal").modal('hide');
397400
})
398401

402+
// $("#uploadnb").click(function () {
403+
404+
// var files = $("#import-notebook-file")[0].files
405+
// let json_content = null
406+
// if (files.length > 0) {
407+
// var content = files[0];
408+
// var reader = new FileReader();
409+
// reader.onload = function (t) {
410+
// json_content = t.target.result;
411+
// let json = JSON.parse(json_content)
412+
413+
// $(".content").empty()
414+
415+
// load_notebook(json);
416+
// }
417+
// reader.readAsText(content);
418+
// }
419+
// })
420+
399421

400422

401423
async function load_data(path) {

notebookjs/src/public/javascripts/utils.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,24 @@ function print_val(val) {
7979
}
8080
}
8181

82-
function viz(name, callback) {
83-
82+
function this_div() {
8483
let id = `#out_${window.current_cell}`
85-
$(`${id}`).append(`<div id=${name}></div>`)
84+
let rand_div_name = `random_div_#${id}`
85+
$(`${id}`).append(`<div id=${rand_div_name}></div>`)
86+
return rand_div_name
87+
}
8688

87-
let cb = callback(name);
88-
// $("#ploty").remove(`${name}`)
8989

90-
return cb
91-
}
90+
// function viz(name, callback) {
91+
// // out_div-1
92+
// let id = `#out_div${window.current_cell}`
93+
// // $(`${id}`).append(`<div id=${name}></div>`)
94+
95+
// let cb = callback(name);
96+
// // $("#ploty").remove(`${name}`)
97+
98+
// return cb
99+
// }
92100

93101
function table(df) {
94102

notebookjs/src/views/layout.hbs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@
143143
</div>
144144
<div class="modal-footer">
145145
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
146-
<button type="button" class="btn btn-primary" id="uploadnb">Import</button>
147146
</div>
148147
</div>
149148
</div>

0 commit comments

Comments
 (0)