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
adfc9910
Commit
adfc9910
authored
Oct 09, 2020
by
Romain Casati
Browse files
Properly using JS URL parser.
parent
be970912
Pipeline
#344858
passed with stages
in 7 minutes and 57 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
notebook/static/notebook/js/notebook.js
View file @
adfc9910
...
...
@@ -3011,8 +3011,10 @@ define([
*/
Notebook
.
prototype
.
toURL
=
function
(
key
=
"
ipynb
"
)
{
const
component
=
JSON
.
stringify
(
this
.
toIpynb
());
const
url
=
encodeURIComponent
(
component
).
replace
(
/
\(
/g
,
'
%28
'
).
replace
(
/
\)
/g
,
'
%29
'
);
return
window
.
location
+
'
?
'
+
key
+
'
=
'
+
url
;
const
url
=
new
URL
(
window
.
location
.
href
);
url
.
hash
=
""
;
url
.
searchParams
.
set
(
key
,
encodeURIComponent
(
component
).
replace
(
/
\(
/g
,
'
%28
'
).
replace
(
/
\)
/g
,
'
%29
'
));
return
url
.
href
;
};
/** [Basthon]
...
...
@@ -3139,21 +3141,10 @@ pas fonctionner avec certains navigateurs.
* Loading the notebook from query string.
*/
Notebook
.
prototype
.
loadFromQS
=
function
(
key
=
"
ipynb
"
)
{
// Get QS from curent URL.
function
queryString
()
{
var
search
=
window
.
location
.
search
;
if
(
search
[
0
]
===
'
?
'
)
{
search
=
search
.
substr
(
1
);
}
var
query
=
{};
for
(
let
param
of
search
.
split
(
'
&
'
)
)
{
const
pair
=
param
.
split
(
"
=
"
);
query
[
pair
[
0
]]
=
decodeURIComponent
(
pair
[
1
]);
}
return
query
;
}
const
params
=
queryString
();
if
(
key
in
params
)
{
const
ipynb
=
params
[
key
]
const
url
=
new
URL
(
window
.
location
.
href
);
var
ipynb
=
url
.
searchParams
.
get
(
key
);
if
(
ipynb
)
{
ipynb
=
decodeURIComponent
(
ipynb
);
this
.
load
(
JSON
.
parse
(
ipynb
));
return
ipynb
;
}
...
...
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