mirror of
https://github.com/luau-lang/luau.git
synced 2025-04-11 22:30:53 +01:00
60 lines
No EOL
1.6 KiB
HTML
60 lines
No EOL
1.6 KiB
HTML
<html lang="en-us">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<title>Luau Web REPL</title>
|
|
</head>
|
|
<body>
|
|
<div>
|
|
<label>Script:</label>
|
|
<br>
|
|
<textarea rows="10" cols="70" id="script"></textarea>
|
|
<br><br>
|
|
<button onclick="clearInput()">
|
|
Clear Input
|
|
</button>
|
|
<button onclick="executeScript()">
|
|
Run
|
|
</button>
|
|
</div>
|
|
<br><br>
|
|
<div>
|
|
<label>Output:</label>
|
|
<br>
|
|
<textarea readonly rows="10" cols="70" id="output"></textarea>
|
|
<br><br>
|
|
<button onclick="clearOutput()">
|
|
Clear Output
|
|
</button>
|
|
</div>
|
|
|
|
<script>
|
|
function output(text) {
|
|
document.getElementById("output").value += new Date().toLocaleTimeString() + ": " + text + "\n";
|
|
}
|
|
|
|
var Module = {
|
|
'print': function (msg) { output(msg) },
|
|
'printErr': function (err) { output(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="luau/Luau.Repl.Web.js"></script>
|
|
</body>
|
|
</html> |