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
831494db
Commit
831494db
authored
Nov 02, 2020
by
Romain Casati
Browse files
Support for loading aux files and modules from URL.
parent
44e07978
Changes
1
Hide whitespace changes
Inline
Side-by-side
notebook/basthon/gui.js
View file @
831494db
...
...
@@ -37,6 +37,14 @@ window.basthonGUI = (function () {
that
.
notebook
.
loadFromStorage
();
}
Basthon
.
Goodies
.
setLoaderText
(
"
Chargement des fichiers auxiliaires...
"
);
// loading aux files from URL
await
that
.
loadURLAux
();
Basthon
.
Goodies
.
setLoaderText
(
"
Chargement des modules annexes...
"
);
// loading modules from URL
await
that
.
loadURLModules
();
Basthon
.
Goodies
.
hideLoader
();
/* saving to storage on multiple events */
...
...
@@ -111,6 +119,43 @@ window.basthonGUI = (function () {
}
};
/**
* Load ressources from URL (common part to files and modules).
*/
that
.
_loadFromURL
=
async
function
(
key
,
put
)
{
const
url
=
new
URL
(
window
.
location
.
href
);
var
promises
=
[];
for
(
var
fileURL
of
url
.
searchParams
.
getAll
(
key
)
)
{
fileURL
=
decodeURIComponent
(
fileURL
);
const
filename
=
fileURL
.
split
(
'
/
'
).
pop
();
var
promise
=
Basthon
.
xhr
({
method
:
"
GET
"
,
url
:
fileURL
,
responseType
:
"
arraybuffer
"
});
promise
=
promise
.
then
(
function
(
data
)
{
return
put
(
filename
,
data
);
}).
catch
(
function
()
{
throw
{
message
:
"
Impossible de charger le fichier
"
+
filename
+
"
.
"
,
name
:
"
LoadingException
"
};
});
promises
.
push
(
promise
);
}
await
Promise
.
all
(
promises
);
};
/**
* Load auxiliary files submited via URL (aux= parameter) (async).
*/
that
.
loadURLAux
=
function
()
{
return
that
.
_loadFromURL
(
'
aux
'
,
Basthon
.
putFile
);
};
/**
* Load modules submited via URL (module= parameter) (async).
*/
that
.
loadURLModules
=
function
()
{
return
that
.
_loadFromURL
(
'
module
'
,
Basthon
.
putModule
);
};
/**
* Copying a string to clipboard.
*/
...
...
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