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
Show 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 @@
...
@@ -423,23 +423,56 @@
}
}
function
executePyCell
(
line_list
)
{
function
executePyCell
(
line_list
)
{
var
result_text
,
code_text
=
line_list
.
join
(
'
\n
'
);
var
result
,
code_text
=
line_list
.
join
(
'
\n
'
);
result_text
=
pyodide
.
runPython
(
code_text
);
result
=
pyodide
.
runPython
(
code_text
);
renderCodeblock
(
result_text
);
console
.
log
(
"
Result is
"
);
console
.
log
(
result
);
renderCodeblock
(
result
);
}
}
function
pyodideSetting
()
{
function
pyodideSetting
()
{
window
.
pyodide
=
pyodide
(
Module
);
window
.
pyodide
=
pyodide
(
Module
);
window
.
pyodide
.
loadPackage
=
pyodideLoadPackage
;
var
defer
=
RSVP
.
defer
(),
promise
=
defer
.
promise
;
var
defer
=
RSVP
.
defer
(),
promise
=
defer
.
promise
;
Module
.
postRun
=
defer
.
resolve
;
Module
.
postRun
=
defer
.
resolve
;
promise
.
then
(
function
()
{
promise
.
then
(
function
()
{
console
.
log
(
"
postRun get called
"
);
console
.
log
(
"
postRun get called
"
);
delete
window
.
Module
;
});
});
return
defer
.
promise
;
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
)
{
function
executeCell
(
cell
)
{
if
([
'
raw
'
,
'
meta
'
,
'
plugin
'
].
indexOf
(
cell
.
_type
)
!==
-
1
)
{
if
([
'
raw
'
,
'
meta
'
,
'
plugin
'
].
indexOf
(
cell
.
_type
)
!==
-
1
)
{
// Do nothing...
// Do nothing...
...
@@ -471,17 +504,10 @@
...
@@ -471,17 +504,10 @@
if
(
!
is_pyodide_loaded
)
{
if
(
!
is_pyodide_loaded
)
{
console
.
log
(
"
Loading pyodide
"
);
console
.
log
(
"
Loading pyodide
"
);
queue
.
push
(
function
()
{
queue
.
push
(
function
()
{
Module
.
instantiateWasm
=
loadPyodide
;
return
initPyodide
();
window
.
Module
=
Module
;
})
.
push
(
function
()
{
return
loadJSResource
(
'
pyodide.asm.data.js
'
);
})
})
.
push
(
function
()
{
.
push
(
function
()
{
return
loadJSResource
(
'
pyodide.asm.js
'
);
return
pyodideLoadPackage
(
'
matplotlib
'
);
})
.
push
(
function
()
{
return
pyodideSetting
();
});
});
is_pyodide_loaded
=
true
;
is_pyodide_loaded
=
true
;
}
}
...
...
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