Skip to content

Commit 63947e8

Browse files
committed
save and load notebook json
1 parent aaad1a0 commit 63947e8

5 files changed

Lines changed: 194 additions & 2 deletions

File tree

notebookjs/src/public/javascripts/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,11 @@ $(document).on("click", "button.add-code", function () {
146146
where = "up"
147147
}
148148
add_new_code_cell(this.id, where)
149-
})
149+
})
150+
151+
$("#download").click(function(){
152+
153+
let out= notebook_json(vars_in_scope);
154+
155+
console.log(out);
156+
});

notebookjs/src/public/javascripts/temp_store.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

notebookjs/src/public/javascripts/utils.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,27 @@ function table(df){
141141

142142
return table;
143143

144+
}
145+
146+
function notebook_json(scope){
147+
148+
var store = {}
149+
150+
for(let key in scope){
151+
152+
let id = key.split("-")[1]
153+
154+
let cell_content = scope[key].getValue()
155+
156+
let cell_output = $(`#out_${key}`).html()
157+
158+
store[`cell-${id}`] = {
159+
"in": cell_content,
160+
"out": cell_output
161+
}
162+
}
163+
164+
store = JSON.stringify(store);
165+
166+
return store
144167
}

notebookjs/src/views/index.hbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
</div>
5656

5757
</div>
58-
<div id="ploty"></div>
58+
59+
<button id="download">Download</button>
5960
</div>
6061

6162

0 commit comments

Comments
 (0)