forked from michaelliao/learn-python3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyscript_plugin.js
More file actions
31 lines (29 loc) · 906 Bytes
/
pyscript_plugin.js
File metadata and controls
31 lines (29 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
export default class LearnPython3Plugin {
afterStartup(runtime) {
console.log('[plugin] pyscript startup.');
window.__pyscript_ready__ = true;
}
afterPyScriptExec(opt) {
let
tag = opt.pyScriptTag,
outputId = tag.getAttribute('output'),
$btn = $('button[outputId=' + outputId + ']'),
$i = $btn.find('i');
$i.removeClass('uk-icon-spinner');
$i.removeClass('uk-icon-spin');
$btn.removeAttr('disabled');
let err = $(tag).find('pre.py-error').html();
if (err) {
let
$out = $('#' + outputId),
s = $out.html();
s = s + err.replaceAll(' ', ' ');
$out.html(s);
$out.addClass('uk-alert-danger');
}
}
onUserError(err) {
console.log('Error >>>');
console.error(err);
}
}