Commit 6c338d0c authored by Boxiang Sun's avatar Boxiang Sun

erp5_notebook: Switch from webworker to single thread implementation

parent 45e2630e
...@@ -53,16 +53,13 @@ ...@@ -53,16 +53,13 @@
}; };
function sideEffectDiv(sideEffectClass, reportSideEffect) { function sideEffectDiv(sideEffectClass, reportSideEffect) {
var div = document.getElementById(py_div_id_prefix + py_div_id_count_2), // appends a side effect div to the side effect area
pre = div.getElementsByTagName('pre')[0], var div = document.createElement("div");
result = pre.getElementsByTagName('code')[0];
py_div_id_count_2 += 1;
div.removeChild(div.firstChild);
div.setAttribute("class", sideEffectClass); div.setAttribute("class", sideEffectClass);
if (reportSideEffect === undefined) { if (reportSideEffect === undefined) {
div.setAttribute("style", "display:"); div.setAttribute("style", "display:");
} }
document.body.appendChild(div);
return div; return div;
} }
...@@ -433,13 +430,18 @@ ...@@ -433,13 +430,18 @@
} }
function renderCodeblock(result_text) { function renderCodeblock(result_text) {
if (result_text !== undefined) { var div = document.createElement('div'),
var div = document.getElementById(py_div_id_prefix + py_div_id_count_2), pre = document.createElement('pre'),
pre = div.getElementsByTagName('pre')[0], result = document.createElement('code');
result = pre.getElementsByTagName('code')[0]; div.style.border = '1px solid #C3CCD0';
div.style.margin = '40px 10px';
div.style.paddingLeft = '10px';
py_div_id_count_2 += 1; if (result_text !== undefined) {
result.innerHTML = result_text; result.innerHTML = result_text;
pre.appendChild(result);
div.appendChild(pre);
document.body.appendChild(div);
} }
} }
...@@ -551,11 +553,10 @@ ...@@ -551,11 +553,10 @@
// empty block, do nothing. // empty block, do nothing.
return; return;
} }
addPyCellStub(); var queue = new RSVP.Queue();
if (!is_pyodide_loaded) { if (is_pyodide_loaded === false) {
props.queue = new RSVP.Queue() queue.push(function () {
.push(function () { return initPyodide();
return initPyodide();
}) })
.push(function () { .push(function () {
return pyodideLoadPackage('matplotlib'); return pyodideLoadPackage('matplotlib');
...@@ -563,10 +564,10 @@ ...@@ -563,10 +564,10 @@
is_pyodide_loaded = true; is_pyodide_loaded = true;
} }
props.queue.push(function () { queue.push(function () {
return executePyCell(cell._line_list); return executePyCell(cell._line_list);
}); });
return; return queue
} }
return executeUnknownCellType(cell); return executeUnknownCellType(cell);
} }
...@@ -590,12 +591,6 @@ ...@@ -590,12 +591,6 @@
queue.push(deferCellExecution(cell_list[i])); queue.push(deferCellExecution(cell_list[i]));
} }
// Python packages loading and execution
queue
.push(function () {
return props.queue;
});
return queue return queue
.push(function () { .push(function () {
console.info('JSMD executed.'); console.info('JSMD executed.');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment