mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
53 lines
No EOL
1.4 KiB
HTML
53 lines
No EOL
1.4 KiB
HTML
<form>
|
|
<div>
|
|
<label>Script:</label>
|
|
<br>
|
|
<textarea rows="10" cols="70" id="script">print("Hello World!")</textarea>
|
|
<br><br>
|
|
<button onclick="clearInput(); return false;">
|
|
Clear Input
|
|
</button>
|
|
<button onclick="executeScript(); return false;">
|
|
Run
|
|
</button>
|
|
</div>
|
|
<br><br>
|
|
<div>
|
|
<label>Output:</label>
|
|
<br>
|
|
<textarea readonly rows="10" cols="70" id="output"></textarea>
|
|
<br><br>
|
|
<button onclick="clearOutput(); return false;">
|
|
Clear Output
|
|
</button>
|
|
</div>
|
|
</form>
|
|
|
|
<script>
|
|
function output(text) {
|
|
document.getElementById("output").value += new Date().toLocaleTimeString() + ": " + text + "\n";
|
|
}
|
|
|
|
var Module = {
|
|
'print': function (msg) { output(msg) },
|
|
'printErr': function (err) { } // potentially unused?
|
|
};
|
|
|
|
function clearInput() {
|
|
document.getElementById("script").value = "";
|
|
}
|
|
|
|
function clearOutput() {
|
|
document.getElementById("output").value = "";
|
|
}
|
|
|
|
function executeScript() {
|
|
try {
|
|
Module.ccall('executeScript', null, ['string'], [document.getElementById("script").value]);
|
|
}
|
|
catch (e) {
|
|
output(Module.ccall('getExceptionFromPtr', 'string', ['number'], [e]).replace('stdin', '[ERROR]'));
|
|
}
|
|
}
|
|
</script>
|
|
<script async src="assets/luau/Luau.Repl.Web.js"></script> |