Commit 8c5b6520 authored by Romain Casati's avatar Romain Casati
Browse files

Support for loading external files (to then load from Python).

parent 3288a322
Pipeline #354648 passed with stages
in 7 minutes and 8 seconds
......@@ -3182,13 +3182,22 @@ pas fonctionner avec certains navigateurs.
input.type = 'file';
input.style.display = "none";
input.onchange = function (event) {
/* TODO: connect filename to notebook name */
const file = event.target.files[0];
var reader = new FileReader();
reader.readAsText(file);
reader.onload = function (event) {
that.load(JSON.parse(event.target.result));
};
for( var file of event.target.files ) {
const ext = file.name.split('.').pop();
var reader = new FileReader();
if(ext === 'ipynb') {
/* TODO: connect filename to notebook name */
reader.readAsText(file);
reader.onload = function (event) {
that.load(JSON.parse(event.target.result));
};
} else {
reader.readAsArrayBuffer(file);
reader.onload = function (event) {
Basthon.putFile(file.name, event.target.result);
};
}
}
};
document.body.appendChild(input);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment