Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Basthon
Basthon Notebook
Commits
90951977
Commit
90951977
authored
Oct 29, 2020
by
Romain Casati
Browse files
Implementing Basthon part GUI as an object.
parent
e7ef80f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
notebook/basthon/gui.js
View file @
90951977
"
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
(
);
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment