Commit 90951977 authored by Romain Casati's avatar Romain Casati
Browse files

Implementing Basthon part GUI as an object.

parent e7ef80f4
"use strict";
/**
* Callback for Basthon loading.
* Basthon part of the notebook GUI.
*/
function onLoad() {
const notebook = Jupyter.notebook;
// avoiding notebook loading failure.
if( !notebook ) {
location.reload();
}
/*
loading content from query string or from local storage.
if global variale basthonEmptyNotebook is set to true,
we open a new notebook
(see kernelselector.js).
window.basthonGUI = (function () {
var that = {};
/**
* Initialise the GUI (Basthon part).
*/
if( !window.basthonEmptyNotebook && !notebook.loadFromQS() ) {
notebook.loadFromStorage();
}
that.init = async function () {
await Basthon.Goodies.showLoader("Chargement de Basthon-Notebook...");
/* saving to storage on multiple events */
function saveCallback() { notebook.saveToStorage(); }
for( let event of ['execute.CodeCell',
'finished_execute.CodeCell',
'output_added.OutputArea',
'output_updated.OutputArea',
'output_appended.OutputArea'] ) {
notebook.events.bind(event, saveCallback);
}
}
const notebook = Jupyter.notebook;
// avoiding notebook loading failure.
if( !notebook ) {
location.reload();
}
/*
loading content from query string or from local storage.
if global variale basthonEmptyNotebook is set to true,
we open a new notebook
(see kernelselector.js).
*/
if( !window.basthonEmptyNotebook && !notebook.loadFromQS() ) {
notebook.loadFromStorage();
}
/* saving to storage on multiple events */
for( let event of ['execute.CodeCell',
'finished_execute.CodeCell',
'output_added.OutputArea',
'output_updated.OutputArea',
'output_appended.OutputArea'] ) {
notebook.events.bind(
event, () => { notebook.saveToStorage(); } );
}
};
return that;
})();
Basthon.Goodies.showLoader("Chargement de Basthon-Notebook...").then(onLoad);
window.basthonGUI.init();
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