Python js in dedicated file

This commit is contained in:
Romain de Laage 2021-04-05 09:49:09 +02:00
parent 743753ee5d
commit 1daeeb6873
Signed by: rdelaage
GPG Key ID: 534845FADDF0C329
2 changed files with 21 additions and 22 deletions

20
assets/js/pypg.js Normal file
View File

@ -0,0 +1,20 @@
const flask = getEditor("#code", "py")
brython({ids:["pyinit"]})
function run() {
document.getElementById("pycode").innerHTML = flask.getCode()
brython({ids:["pyclear"]})
brython({
debug:1,
ids:["pycode"]
})
}
function example() {
flask.updateCode("def foo(n):\n for i in range(n):\n print('passe ' + str(i))\n return n*n\n\nprint(foo(5))")
}
function clearCode() {
flask.updateCode("")
}

View File

@ -51,27 +51,6 @@ document['console'].html = ''
</script>
<script type="text/python" id="pycode"></script>
<script src="assets/js/editor.js"></script>
<script>
const flask = getEditor("#code", "py")
brython({ids:["pyinit"]})
function run() {
document.getElementById("pycode").innerHTML = flask.getCode()
brython({ids:["pyclear"]})
brython({
debug:1,
ids:["pycode"]
})
}
function example() {
flask.updateCode("def foo(n):\n for i in range(n):\n print('passe ' + str(i))\n return n*n\n\nprint(foo(5))")
}
function clearCode() {
flask.updateCode("")
}
</script>
<script src="assets/js/pypg.js"></script>
</body>
</html>