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