From 1daeeb6873350d3deaf63491b910914b3fec2a7f Mon Sep 17 00:00:00 2001 From: Romain de Laage Date: Mon, 5 Apr 2021 09:49:09 +0200 Subject: [PATCH] Python js in dedicated file --- assets/js/pypg.js | 20 ++++++++++++++++++++ python.html | 23 +---------------------- 2 files changed, 21 insertions(+), 22 deletions(-) create mode 100644 assets/js/pypg.js diff --git a/assets/js/pypg.js b/assets/js/pypg.js new file mode 100644 index 0000000..09b1589 --- /dev/null +++ b/assets/js/pypg.js @@ -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("") +} diff --git a/python.html b/python.html index a0f1887..261fc4b 100644 --- a/python.html +++ b/python.html @@ -51,27 +51,6 @@ document['console'].html = '' - +