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
2ddf2d6a
Commit
2ddf2d6a
authored
Apr 01, 2019
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_notebook: Remove independent custom_pyodide.js file
Merge the code to gadget_jsmd_eval.js
parent
0f16aaa5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
22 deletions
+92
-22
bt5/erp5_notebook/SkinTemplateItem/portal_skins/erp5_notebook/gadget_jsmd_eval.html.html
...tem/portal_skins/erp5_notebook/gadget_jsmd_eval.html.html
+0
-1
bt5/erp5_notebook/SkinTemplateItem/portal_skins/erp5_notebook/gadget_jsmd_eval.js.js
...ateItem/portal_skins/erp5_notebook/gadget_jsmd_eval.js.js
+92
-21
No files found.
bt5/erp5_notebook/SkinTemplateItem/portal_skins/erp5_notebook/gadget_jsmd_eval.html.html
View file @
2ddf2d6a
...
...
@@ -11,7 +11,6 @@
<script
src=
"rsvp.js"
type=
"text/javascript"
></script>
<script
src=
"marked.js"
type=
"text/javascript"
></script>
<script
src=
"custom_pyodide.js"
type=
"text/javascript"
></script>
<script
src=
"gadget_jsmd_eval.js"
type=
"text/javascript"
></script>
</head>
...
...
bt5/erp5_notebook/SkinTemplateItem/portal_skins/erp5_notebook/gadget_jsmd_eval.js.js
View file @
2ddf2d6a
/*global window, console, RSVP, document, URL, eval, XMLHttpRequest, marked, pyodide */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(
function
(
window
,
initPyodide
)
{
(
function
(
window
)
{
"
use strict
"
;
var
IODide
=
function
createIODide
()
{
...
...
@@ -11,13 +11,38 @@
this
.
_line_list
=
line_list
;
},
split_line_regex
=
/
[\r\n
|
\n
|
\r]
/
,
cell_type_regexp
=
/^
\%\%
(\w
+
)
$/
;
cell_type_regexp
=
/^
\%\%
(\w
+
)
$/
,
is_pyodide_loaded
=
false
;
window
.
iodide
=
new
IODide
();
window
.
x
iodide
=
new
IODide
();
IODide
.
prototype
.
addOutputHandler
=
function
()
{
return
;
};
var
Module
=
{};
var
initPyodide
=
new
Promise
((
resolve
,
reject
)
=>
{
var
postRunPromise
=
new
Promise
((
resolve
,
reject
)
=>
{
Module
.
postRun
=
()
=>
{
resolve
();
};
});
Promise
.
all
([
postRunPromise
,
]).
then
(()
=>
resolve
());
let
data_script
=
document
.
createElement
(
'
script
'
);
data_script
.
src
=
`pyodide.asm.data.js`
;
data_script
.
onload
=
(
event
)
=>
{
let
script
=
document
.
createElement
(
'
script
'
);
script
.
src
=
`pyodide.asm.js`
;
script
.
onload
=
()
=>
{
window
.
pyodide
=
pyodide
(
Module
);
};
document
.
head
.
appendChild
(
script
);
};
document
.
head
.
appendChild
(
data_script
);
});
// Copied from jio
function
ajax
(
param
)
{
...
...
@@ -254,22 +279,30 @@
});
}
function
loadPyodide
()
{
let
wasm_promise
=
WebAssembly
.
compileStreaming
(
fetch
(
`pyodide.asm.wasm`
));
Module
.
instantiateWasm
=
function
(
info
,
receiveInstance
)
{
wasm_promise
.
then
(
module
=>
WebAssembly
.
instantiate
(
module
,
info
))
.
then
(
instance
=>
receiveInstance
(
instance
));
return
{};
};
}
function
executePyCell
(
line_list
)
{
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
var
result_text
,
code_text
=
line_list
.
join
(
'
\n
'
);
try
{
result_text
=
pyodide
.
runPython
(
line_list
.
join
(
'
\n
'
));
}
catch
(
e
)
{
result_text
=
e
.
message
;
}
var
result_text
,
code_text
=
line_list
.
join
(
'
\n
'
);
if
(
typeof
(
result_text
)
===
'
undefined
'
)
{
result_text
=
'
undefined
'
;
}
try
{
result_text
=
pyodide
.
runPython
(
line_list
.
join
(
'
\n
'
));
}
catch
(
e
)
{
result_text
=
e
.
message
;
}
renderCodeblock
(
result_text
,
'
python
'
);
resolve
();
});
if
(
typeof
(
result_text
)
===
'
undefined
'
)
{
result_text
=
'
undefined
'
;
}
renderCodeblock
(
result_text
,
'
python
'
);
}
function
renderCodeblock
(
result_text
,
language
)
{
...
...
@@ -309,7 +342,48 @@
return
executeCssCell
(
cell
.
_line_list
);
}
if
(
cell
.
_type
===
'
py
'
)
{
return
executePyCell
(
cell
.
_line_list
);
console
.
log
(
"
Py cell
"
);
console
.
log
(
is_pyodide_loaded
);
var
queue
=
new
RSVP
.
Queue
();
if
(
!
is_pyodide_loaded
)
{
console
.
log
(
"
Loading pyodide
"
);
queue
.
push
(
function
()
{
console
.
log
(
"
Loading webassembly module
"
);
return
loadPyodide
();
})
.
push
(
function
()
{
window
.
Module
=
Module
;
console
.
log
(
"
WIndow Module
"
);
console
.
log
(
window
.
Module
);
console
.
log
(
"
Module
"
);
console
.
log
(
Module
);
})
.
push
(
function
()
{
console
.
log
(
"
Prepare enter initPyodide
"
);
return
initPyodide
;
});
is_pyodide_loaded
=
true
;
/*
queue.push(function () {
console.log("Loading pyodide.asm.data.js");
return loadJSResource(`pyodide.asm.data.js`);
});*/
/*
queue.push(function () {
console.log("Loading pyodide.asm.js");
return loadJSResource('pyodide.asm.js');
});
*/
}
console
.
log
(
"
Fuck!
"
);
queue
.
push
(
function
()
{
console
.
log
(
"
Executing Python cell
"
);
console
.
log
(
window
.
pyodide
);
return
executePyCell
(
cell
.
_line_list
);
});
return
queue
;
}
return
executeUnknownCellType
(
cell
);
}
...
...
@@ -329,9 +403,6 @@
i
,
queue
=
new
RSVP
.
Queue
();
queue
.
push
(
function
()
{
return
initPyodide
;
});
for
(
i
=
0
;
i
<
len
;
i
+=
1
)
{
queue
.
push
(
deferCellExecution
(
cell_list
[
i
]));
}
...
...
@@ -352,4 +423,4 @@
},
false
);
}(
window
,
initPyodide
));
\ No newline at end of file
}(
window
));
\ No newline at end of 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