Fix minor bug
This commit is contained in:
parent
a22833c3e8
commit
acd374085e
@ -114,13 +114,6 @@
|
|||||||
/*Initialize MicroPython itself*/
|
/*Initialize MicroPython itself*/
|
||||||
mp_js_init(1 * 1024 * 1024);
|
mp_js_init(1 * 1024 * 1024);
|
||||||
|
|
||||||
/* Run custom script if passed */
|
|
||||||
var custom = getSearchArg("script");
|
|
||||||
console.log("Custom script: " + custom);
|
|
||||||
if(custom !== undefined && custom !== null)
|
|
||||||
processScriptArg(custom);
|
|
||||||
|
|
||||||
|
|
||||||
var compressedScript = window.parent.document.getElementById("emscripten-iframe").getAttribute("data-cscript");
|
var compressedScript = window.parent.document.getElementById("emscripten-iframe").getAttribute("data-cscript");
|
||||||
if(compressedScript !== undefined && compressedScript !== null)
|
if(compressedScript !== undefined && compressedScript !== null)
|
||||||
decompressScript(compressedScript);
|
decompressScript(compressedScript);
|
||||||
@ -136,6 +129,10 @@
|
|||||||
/*Start the main loop, asynchronously.*/
|
/*Start the main loop, asynchronously.*/
|
||||||
handle_pending();
|
handle_pending();
|
||||||
}
|
}
|
||||||
|
window.onload = function() {
|
||||||
|
console.log("onload");
|
||||||
|
startRunning();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -91,7 +91,7 @@
|
|||||||
<div id="mp_js_stdout"></div>
|
<div id="mp_js_stdout"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<iframe onload="reloaded();" id="emscripten-iframe"></iframe>
|
<iframe onload="reloaded();" src="about:blank" id="emscripten-iframe"></iframe>
|
||||||
<script>
|
<script>
|
||||||
var editor, iframe;
|
var editor, iframe;
|
||||||
var iframe_html;
|
var iframe_html;
|
||||||
@ -110,17 +110,22 @@
|
|||||||
$this.prop("disabled", true);
|
$this.prop("disabled", true);
|
||||||
term.write('\x1bc');
|
term.write('\x1bc');
|
||||||
|
|
||||||
|
|
||||||
|
const context = document.getElementById("canvas").getContext('2d');
|
||||||
|
|
||||||
|
context.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
iframe.setAttribute("data-cscript", LZString.compressToEncodedURIComponent(editor.getValue()));
|
iframe.setAttribute("data-cscript", LZString.compressToEncodedURIComponent(editor.getValue()));
|
||||||
|
|
||||||
console.log(iframe.src);
|
console.log(iframe.src);
|
||||||
|
clear_iframe(iframe);
|
||||||
var doc = iframe.contentWindow.document;
|
var doc = iframe.contentWindow.document;
|
||||||
doc.open();
|
doc.open();
|
||||||
doc.write(iframe_html);
|
doc.write(iframe_html);
|
||||||
doc.close();
|
doc.close();
|
||||||
iframe.onload = function() {
|
|
||||||
$this.removeProp("disabled");
|
|
||||||
iframe.contentWindow.startRunning();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
function get_iframe_url() {
|
function get_iframe_url() {
|
||||||
/* Assemble the URL */
|
/* Assemble the URL */
|
||||||
@ -144,14 +149,13 @@
|
|||||||
request.send(null);
|
request.send(null);
|
||||||
request.onreadystatechange = function () {
|
request.onreadystatechange = function () {
|
||||||
if (request.readyState === 4 && request.status === 200) {
|
if (request.readyState === 4 && request.status === 200) {
|
||||||
var type = request.getResponseHeader('Content-Type');
|
|
||||||
if (type.indexOf("text") !== 1) {
|
|
||||||
console.log(request.reponseText);
|
console.log(request.reponseText);
|
||||||
if(request.responseText === undefined)
|
if(request.responseText === undefined)
|
||||||
return;
|
return;
|
||||||
editor.session.getUndoManager().reset();
|
editor.session.getUndoManager().reset();
|
||||||
editor.setValue(request.responseText, -1);
|
editor.setValue(request.responseText, -1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,7 +174,7 @@
|
|||||||
iframe.contentWindow.document.write("");
|
iframe.contentWindow.document.write("");
|
||||||
iframe.contentWindow.document.close();
|
iframe.contentWindow.document.close();
|
||||||
}
|
}
|
||||||
window.onload = function() {
|
$(window).load(function() {
|
||||||
editor = ace.edit("editor");
|
editor = ace.edit("editor");
|
||||||
editor.setAutoScrollEditorIntoView(true);
|
editor.setAutoScrollEditorIntoView(true);
|
||||||
var PythonMode = ace.require("ace/mode/python").Mode;
|
var PythonMode = ace.require("ace/mode/python").Mode;
|
||||||
@ -205,6 +209,7 @@
|
|||||||
var request = new XMLHttpRequest();
|
var request = new XMLHttpRequest();
|
||||||
|
|
||||||
request.open('GET', get_iframe_url(), true);
|
request.open('GET', get_iframe_url(), true);
|
||||||
|
request.overrideMimeType("text/plain; charset=x-user-defined");
|
||||||
request.send(null);
|
request.send(null);
|
||||||
request.onreadystatechange = function () {
|
request.onreadystatechange = function () {
|
||||||
if (request.readyState === 4 && request.status === 200 && request.responseText !== undefined && request.responseText != null) {
|
if (request.readyState === 4 && request.status === 200 && request.responseText !== undefined && request.responseText != null) {
|
||||||
@ -212,7 +217,7 @@
|
|||||||
$("#run-button").removeProp("disabled");
|
$("#run-button").removeProp("disabled");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user