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
235ddb75
Commit
235ddb75
authored
Oct 29, 2020
by
Romain Casati
Browse files
Download function goes from notebook to GUI.
parent
68e38863
Changes
4
Hide whitespace changes
Inline
Side-by-side
notebook/basthon/gui.js
View file @
235ddb75
...
...
@@ -38,7 +38,7 @@ window.basthonGUI = (function () {
'
output_updated.OutputArea
'
,
'
output_appended.OutputArea
'
]
)
{
that
.
notebook
.
events
.
bind
(
event
,
()
=>
{
that
.
notebook
.
saveToStorage
();
}
);
event
,
()
=>
{
that
.
saveToStorage
();
}
);
}
};
...
...
@@ -136,6 +136,29 @@ Un lien vers la page de Basthon avec le contenu actuel du script a été créé.
});
that
.
notebook
.
events
.
trigger
(
'
notebook_shared.Notebook
'
);
};
/**
* Saving notebook to local storage.
*/
that
.
saveToStorage
=
function
()
{
that
.
notebook
.
saveToStorage
();
};
/**
* Download notebook to file.
*/
that
.
download
=
function
()
{
const
content
=
JSON
.
stringify
(
that
.
notebook
.
toJSON
());
var
blob
=
new
Blob
([
content
],
{
type
:
"
text/plain
"
});
var
anchor
=
document
.
createElement
(
"
a
"
);
anchor
.
download
=
that
.
notebook
.
notebook_name
;
anchor
.
href
=
window
.
URL
.
createObjectURL
(
blob
);
anchor
.
target
=
"
_blank
"
;
anchor
.
style
.
display
=
"
none
"
;
// just to be safe!
document
.
body
.
appendChild
(
anchor
);
anchor
.
click
();
document
.
body
.
removeChild
(
anchor
);
};
return
that
;
})();
...
...
notebook/static/notebook/js/actions.js
View file @
235ddb75
...
...
@@ -877,8 +877,8 @@ define([
help_index
:
'
fc
'
,
icon
:
'
fa-save
'
,
handler
:
function
(
env
,
event
)
{
env
.
notebook
.
saveToStorage
();
env
.
notebook
.
download
();
basthonGUI
.
saveToStorage
();
basthonGUI
.
download
();
if
(
event
){
event
.
preventDefault
();
}
...
...
notebook/static/notebook/js/menubar.js
View file @
235ddb75
...
...
@@ -166,7 +166,7 @@ define([
return
false
;
});
this
.
element
.
find
(
'
#save_notebook_as
'
).
click
(
function
()
{
that
.
notebook
.
download
();
basthonGUI
.
download
();
return
false
;
});
...
...
notebook/static/notebook/js/notebook.js
View file @
235ddb75
...
...
@@ -3077,23 +3077,6 @@ define([
}
};
/**
* [Basthon]
* Download notebook to file.
*/
Notebook
.
prototype
.
download
=
function
()
{
const
content
=
JSON
.
stringify
(
this
.
toJSON
());
var
blob
=
new
Blob
([
content
],
{
type
:
"
text/plain
"
});
var
anchor
=
document
.
createElement
(
"
a
"
);
anchor
.
download
=
this
.
notebook_name
;
anchor
.
href
=
window
.
URL
.
createObjectURL
(
blob
);
anchor
.
target
=
"
_blank
"
;
anchor
.
style
.
display
=
"
none
"
;
// just to be safe!
document
.
body
.
appendChild
(
anchor
);
anchor
.
click
();
document
.
body
.
removeChild
(
anchor
);
};
/**
* [Basthon]
* Open notebook from file.
...
...
Write
Preview
Markdown
is supported
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