mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
69 lines
No EOL
2 KiB
HTML
69 lines
No EOL
2 KiB
HTML
<form>
|
|
<div>
|
|
<label>Script:</label>
|
|
<br>
|
|
<textarea rows="10" cols="70" id="script"></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>
|
|
|
|
<!-- Luau WASM (async fetch) -->
|
|
<script async src="https://github.com/Roblox/luau/releases/download/0.505/Luau.Web.js"></script>
|
|
<!-- CodeMirror -->
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/codemirror.min.js"></script>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/codemirror.min.css" />
|
|
<!-- Luau Parser for CodeMirror -->
|
|
<script src="assets/js/luau_mode.js"></script>
|
|
|
|
<!-- CodeMirror Luau Editor (MUST BE LOADED AFTER CODEMIRROR!) -->
|
|
<script>
|
|
var editor = CodeMirror.fromTextArea(document.getElementById("script"), {
|
|
theme: "default",
|
|
mode: "luau",
|
|
matchBrackets: true,
|
|
lineNumbers: true,
|
|
smartIndent: true,
|
|
});
|
|
editor.setValue("print(\"Hello World!\")\n");
|
|
|
|
// Misc Functions
|
|
function output(text) {
|
|
document.getElementById("output").value += "[" + new Date().toLocaleTimeString() + "] " + text.replace('stdin:', '') + "\n";
|
|
}
|
|
|
|
var Module = {
|
|
'print': function (msg) { output(msg) }
|
|
};
|
|
|
|
function clearInput() {
|
|
document.getElementById("script").value = "";
|
|
}
|
|
|
|
function clearOutput() {
|
|
document.getElementById("output").value = "";
|
|
}
|
|
|
|
function executeScript() {
|
|
var err = Module.ccall('executeScript', 'string', ['string'], [editor.getValue()]);
|
|
if (err) {
|
|
output('Error:' + err.replace('stdin:', ''));
|
|
}
|
|
}
|
|
</script>
|
|
|