Read Emscripten HTML manually to avoid Content-Type issues
This commit is contained in:
parent
a16c4e177d
commit
a22833c3e8
@ -94,6 +94,7 @@
|
|||||||
<iframe onload="reloaded();" id="emscripten-iframe"></iframe>
|
<iframe onload="reloaded();" id="emscripten-iframe"></iframe>
|
||||||
<script>
|
<script>
|
||||||
var editor, iframe;
|
var editor, iframe;
|
||||||
|
var iframe_html;
|
||||||
function reloaded() {
|
function reloaded() {
|
||||||
console.log("Loaded iframe");
|
console.log("Loaded iframe");
|
||||||
}
|
}
|
||||||
@ -108,6 +109,20 @@
|
|||||||
var $this = $("#run-button");
|
var $this = $("#run-button");
|
||||||
$this.prop("disabled", true);
|
$this.prop("disabled", true);
|
||||||
term.write('\x1bc');
|
term.write('\x1bc');
|
||||||
|
|
||||||
|
iframe.setAttribute("data-cscript", LZString.compressToEncodedURIComponent(editor.getValue()));
|
||||||
|
|
||||||
|
console.log(iframe.src);
|
||||||
|
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 */
|
/* Assemble the URL */
|
||||||
var newPathname = "";
|
var newPathname = "";
|
||||||
var pathArray = window.location.pathname.split('/');
|
var pathArray = window.location.pathname.split('/');
|
||||||
@ -119,14 +134,7 @@
|
|||||||
newPathname += pathArray[i];
|
newPathname += pathArray[i];
|
||||||
}
|
}
|
||||||
newPathname += "/lvgl.html?env=dev";
|
newPathname += "/lvgl.html?env=dev";
|
||||||
iframe.setAttribute("data-cscript", LZString.compressToEncodedURIComponent(editor.getValue()));
|
return window.location.protocol + "//" + window.location.host + newPathname;
|
||||||
|
|
||||||
iframe.src = window.location.protocol + "//" + window.location.host + newPathname;
|
|
||||||
console.log(iframe.src);
|
|
||||||
iframe.onload = function() {
|
|
||||||
$this.removeProp("disabled");
|
|
||||||
iframe.contentWindow.startRunning();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
function processScriptArg(url){
|
function processScriptArg(url){
|
||||||
// read text from URL location
|
// read text from URL location
|
||||||
@ -192,6 +200,18 @@
|
|||||||
text = e.data;
|
text = e.data;
|
||||||
term.write(text);
|
term.write(text);
|
||||||
}, false);
|
}, false);
|
||||||
|
$("#run-button").prop("disabled", true);
|
||||||
|
// read text from URL location
|
||||||
|
var request = new XMLHttpRequest();
|
||||||
|
|
||||||
|
request.open('GET', get_iframe_url(), true);
|
||||||
|
request.send(null);
|
||||||
|
request.onreadystatechange = function () {
|
||||||
|
if (request.readyState === 4 && request.status === 200 && request.responseText !== undefined && request.responseText != null) {
|
||||||
|
iframe_html = request.responseText;
|
||||||
|
$("#run-button").removeProp("disabled");
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user