Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5-Boxiang
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hamza
erp5-Boxiang
Commits
299ff77f
Commit
299ff77f
authored
Apr 05, 2019
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_notebook: Extract pyodide initialization code to a independent function
parent
e8cfcaf0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
14 deletions
+40
-14
bt5/erp5_notebook/SkinTemplateItem/portal_skins/erp5_notebook/gadget_jsmd_eval.js.js
...ateItem/portal_skins/erp5_notebook/gadget_jsmd_eval.js.js
+40
-14
No files found.
bt5/erp5_notebook/SkinTemplateItem/portal_skins/erp5_notebook/gadget_jsmd_eval.js.js
View file @
299ff77f
...
...
@@ -423,23 +423,56 @@
}
function
executePyCell
(
line_list
)
{
var
result_text
,
code_text
=
line_list
.
join
(
'
\n
'
);
result_text
=
pyodide
.
runPython
(
code_text
);
renderCodeblock
(
result_text
);
var
result
,
code_text
=
line_list
.
join
(
'
\n
'
);
result
=
pyodide
.
runPython
(
code_text
);
console
.
log
(
"
Result is
"
);
console
.
log
(
result
);
renderCodeblock
(
result
);
}
function
pyodideSetting
()
{
window
.
pyodide
=
pyodide
(
Module
);
window
.
pyodide
.
loadPackage
=
pyodideLoadPackage
;
var
defer
=
RSVP
.
defer
(),
promise
=
defer
.
promise
;
Module
.
postRun
=
defer
.
resolve
;
promise
.
then
(
function
()
{
console
.
log
(
"
postRun get called
"
);
delete
window
.
Module
;
});
return
defer
.
promise
;
}
function
initPyodide
()
{
var
queue
=
new
RSVP
.
Queue
();
queue
.
push
(
function
()
{
Module
.
instantiateWasm
=
loadPyodide
;
window
.
Module
=
Module
;
})
.
push
(
function
()
{
return
loadJSResource
(
'
pyodide.asm.data.js
'
);
})
.
push
(
function
()
{
return
loadJSResource
(
'
pyodide.asm.js
'
);
})
.
push
(
function
()
{
return
pyodideSetting
();
})
.
push
(
function
()
{
return
fetch
(
`packages.json`
)
})
.
push
(
function
(
response
)
{
return
response
.
json
();
})
.
push
(
function
(
json
)
{
window
.
pyodide
.
packages
=
json
;
return
;
});
return
queue
;
}
function
executeCell
(
cell
)
{
if
([
'
raw
'
,
'
meta
'
,
'
plugin
'
].
indexOf
(
cell
.
_type
)
!==
-
1
)
{
// Do nothing...
...
...
@@ -471,18 +504,11 @@
if
(
!
is_pyodide_loaded
)
{
console
.
log
(
"
Loading pyodide
"
);
queue
.
push
(
function
()
{
Module
.
instantiateWasm
=
loadPyodide
;
window
.
Module
=
Module
;
return
initPyodide
();
})
.
push
(
function
()
{
return
loadJSResource
(
'
pyodide.asm.data.js
'
);
})
.
push
(
function
()
{
return
loadJSResource
(
'
pyodide.asm.js
'
);
})
.
push
(
function
()
{
return
pyodideSetting
();
});
.
push
(
function
()
{
return
pyodideLoadPackage
(
'
matplotlib
'
);
});
is_pyodide_loaded
=
true
;
}
queue
.
push
(
function
()
{
...
...
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