Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
1
Merge Requests
1
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
Boxiang Sun
erp5
Commits
45e2630e
Commit
45e2630e
authored
Jun 10, 2019
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_notebook: jsmd_eval code refinement
parent
20d7ab86
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
23 deletions
+37
-23
bt5/erp5_notebook/SkinTemplateItem/portal_skins/erp5_notebook/gadget_jsmd_eval.js.js
...ateItem/portal_skins/erp5_notebook/gadget_jsmd_eval.js.js
+37
-23
No files found.
bt5/erp5_notebook/SkinTemplateItem/portal_skins/erp5_notebook/gadget_jsmd_eval.js.js
View file @
45e2630e
...
@@ -8,7 +8,6 @@
...
@@ -8,7 +8,6 @@
output
:
{
output
:
{
text
:
function
(
s
,
reportSideEffect
)
{
text
:
function
(
s
,
reportSideEffect
)
{
var
i
,
div
,
line_list
;
var
i
,
div
,
line_list
;
console
.
log
(
"
Inside output.text
"
);
console
.
log
(
s
);
console
.
log
(
s
);
line_list
=
s
.
toString
().
split
(
"
\n
"
);
line_list
=
s
.
toString
().
split
(
"
\n
"
);
for
(
i
=
0
;
i
<
line_list
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
line_list
.
length
;
i
+=
1
)
{
...
@@ -145,15 +144,12 @@
...
@@ -145,15 +144,12 @@
package_uri
=
'
default channel
'
;
package_uri
=
'
default channel
'
;
}
}
console
.
log
(
"
Loading
"
+
package_name
+
"
from
"
+
package_uri
);
console
.
log
(
"
Loaded packages
"
);
console
.
log
(
loadedPackages
);
if
(
package_name
in
loadedPackages
)
{
if
(
package_name
in
loadedPackages
)
{
if
(
package_uri
!==
loadedPackages
[
package_name
])
{
if
(
package_uri
!==
loadedPackages
[
package_name
])
{
throw
new
Error
(
throw
new
Error
(
"
URI mismatch, attempting to load package
"
+
"
URI mismatch, attempting to load package
"
+
package_name
+
"
from
"
+
package_uri
+
"
while it is already
"
+
package_name
+
"
from
"
+
package_uri
+
"
while it is already
"
+
"
loaded from
"
+
loadedPackages
[
package_name
]
+
"
!
"
"
loaded from
"
+
loadedPackages
[
package_name
]
+
"
!
"
);
);
}
}
}
else
{
}
else
{
...
@@ -166,7 +162,7 @@
...
@@ -166,7 +162,7 @@
}
}
}
}
}
else
{
}
else
{
console
.
log
(
"
Unknown package
"
+
package_name
);
throw
new
Error
(
"
Unknown package
"
+
package_name
);
}
}
}
}
}
}
...
@@ -207,7 +203,7 @@
...
@@ -207,7 +203,7 @@
// see the new files. This is done here so it happens in parallel
// see the new files. This is done here so it happens in parallel
// with the fetching over the network.
// with the fetching over the network.
window
.
pyodide
.
runPython
(
'
import importlib as _importlib
\n
'
+
window
.
pyodide
.
runPython
(
'
import importlib as _importlib
\n
'
+
'
_importlib.invalidate_caches()
\n
'
);
'
_importlib.invalidate_caches()
\n
'
);
});
});
return
promise
;
return
promise
;
}
}
...
@@ -227,7 +223,7 @@
...
@@ -227,7 +223,7 @@
function
pushNewCell
()
{
function
pushNewCell
()
{
if
(
current_type
!==
undefined
)
{
if
(
current_type
!==
undefined
)
{
cell_list
.
push
(
new
JSMDCell
(
current_type
[
1
],
cell_list
.
push
(
new
JSMDCell
(
current_type
[
1
],
current_text_list
));
current_text_list
));
}
}
}
}
...
@@ -347,7 +343,9 @@
...
@@ -347,7 +343,9 @@
console
.
log
(
line_split
);
console
.
log
(
line_split
);
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
ajax
({
url
:
url
});
return
ajax
({
url
:
url
});
})
})
.
push
(
function
(
evt
)
{
.
push
(
function
(
evt
)
{
window
[
variable
]
=
evt
.
target
.
responseText
;
window
[
variable
]
=
evt
.
target
.
responseText
;
...
@@ -398,9 +396,10 @@
...
@@ -398,9 +396,10 @@
function
executeMarkdownCell
(
line_list
)
{
function
executeMarkdownCell
(
line_list
)
{
var
renderer
=
new
marked
.
Renderer
();
var
renderer
=
new
marked
.
Renderer
();
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
marked
(
line_list
.
join
(
'
\n
'
),
marked
(
line_list
.
join
(
'
\n
'
),
{
{
renderer
:
renderer
},
renderer
:
renderer
function
(
err
,
content
)
{
},
function
(
err
,
content
)
{
if
(
err
)
{
if
(
err
)
{
reject
(
err
);
reject
(
err
);
}
}
...
@@ -416,15 +415,18 @@
...
@@ -416,15 +415,18 @@
function
loadPyodide
(
info
,
receiveInstance
)
{
function
loadPyodide
(
info
,
receiveInstance
)
{
var
queue
=
new
RSVP
.
Queue
();
var
queue
=
new
RSVP
.
Queue
();
queue
.
push
(
function
()
{
queue
.
push
(
function
()
{
return
ajax
({
url
:
"
pyodide.asm.wasm
"
,
dataType
:
"
arraybuffer
"
})
return
ajax
({
})
url
:
"
pyodide.asm.wasm
"
,
dataType
:
"
arraybuffer
"
})
})
.
push
(
function
(
evt
)
{
.
push
(
function
(
evt
)
{
return
WebAssembly
.
instantiate
(
evt
.
target
.
response
,
info
);
return
WebAssembly
.
instantiate
(
evt
.
target
.
response
,
info
);
})
})
.
push
(
function
(
results
)
{
.
push
(
function
(
results
)
{
return
receiveInstance
(
results
.
instance
);
return
receiveInstance
(
results
.
instance
);
})
})
.
push
(
undefined
,
function
(
error
)
{
.
push
(
undefined
,
function
(
error
)
{
console
.
log
(
error
);
console
.
log
(
error
);
});
});
return
queue
;
return
queue
;
...
@@ -460,7 +462,7 @@
...
@@ -460,7 +462,7 @@
function
executePyCell
(
line_list
)
{
function
executePyCell
(
line_list
)
{
var
result
,
code_text
=
line_list
.
join
(
'
\n
'
);
var
result
,
code_text
=
line_list
.
join
(
'
\n
'
);
result
=
pyodide
.
runPython
(
code_text
);
result
=
window
.
pyodide
.
runPython
(
code_text
);
renderCodeblock
(
result
);
renderCodeblock
(
result
);
}
}
...
@@ -468,7 +470,8 @@
...
@@ -468,7 +470,8 @@
window
.
pyodide
=
pyodide
(
Module
);
window
.
pyodide
=
pyodide
(
Module
);
window
.
pyodide
.
loadPackage
=
pyodideLoadPackage
;
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
()
{
...
@@ -479,12 +482,21 @@
...
@@ -479,12 +482,21 @@
return
defer
.
promise
;
return
defer
.
promise
;
}
}
Module
.
checkABI
=
function
(
ABI_number
)
{
if
(
ABI_number
!==
parseInt
(
'
1
'
))
{
var
ABI_mismatch_exception
=
`ABI numbers differ. Expected 1, got
${
ABI_number
}
`
;
console
.
error
(
ABI_mismatch_exception
);
throw
ABI_mismatch_exception
;
}
return
true
;
};
function
initPyodide
()
{
function
initPyodide
()
{
var
queue
=
new
RSVP
.
Queue
();
var
queue
=
new
RSVP
.
Queue
();
queue
.
push
(
function
()
{
queue
.
push
(
function
()
{
Module
.
instantiateWasm
=
loadPyodide
;
Module
.
instantiateWasm
=
loadPyodide
;
window
.
Module
=
Module
;
window
.
Module
=
Module
;
})
})
.
push
(
function
()
{
.
push
(
function
()
{
return
loadJSResource
(
'
pyodide.asm.data.js
'
);
return
loadJSResource
(
'
pyodide.asm.data.js
'
);
})
})
...
@@ -495,7 +507,9 @@
...
@@ -495,7 +507,9 @@
return
pyodideSetting
();
return
pyodideSetting
();
})
})
.
push
(
function
()
{
.
push
(
function
()
{
return
ajax
({
url
:
'
packages.json
'
});
return
ajax
({
url
:
'
packages.json
'
});
})
})
.
push
(
function
(
evt
)
{
.
push
(
function
(
evt
)
{
return
JSON
.
parse
(
evt
.
target
.
response
);
return
JSON
.
parse
(
evt
.
target
.
response
);
...
@@ -506,7 +520,7 @@
...
@@ -506,7 +520,7 @@
window
.
pyodide
.
_module
.
packages
=
json
;
window
.
pyodide
.
_module
.
packages
=
json
;
return
;
return
;
})
})
.
push
(
undefined
,
function
(
error
)
{
.
push
(
undefined
,
function
(
error
)
{
console
.
log
(
error
);
console
.
log
(
error
);
});
});
return
queue
;
return
queue
;
...
...
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