mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
move demo repl to docs
This commit is contained in:
parent
bb987daf19
commit
cda27b258b
5 changed files with 63 additions and 64 deletions
|
@ -1,60 +0,0 @@
|
||||||
<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>
|
|
|
@ -39,12 +39,9 @@ if(LUAU_BUILD_WEB_REPL AND EMSCRIPTEN)
|
||||||
|
|
||||||
# declare exported functions to emscripten
|
# declare exported functions to emscripten
|
||||||
target_link_options(Luau.Repl.Web PRIVATE -sEXPORTED_FUNCTIONS=['_getExceptionFromPtr','_executeScript'] -sEXPORTED_RUNTIME_METHODS=['ccall','cwrap'] -sNO_DISABLE_EXCEPTION_CATCHING)
|
target_link_options(Luau.Repl.Web PRIVATE -sEXPORTED_FUNCTIONS=['_getExceptionFromPtr','_executeScript'] -sEXPORTED_RUNTIME_METHODS=['ccall','cwrap'] -sNO_DISABLE_EXCEPTION_CATCHING)
|
||||||
|
|
||||||
# copy html directory
|
|
||||||
add_custom_command(TARGET Luau.Repl.Web PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/CLI/html ${CMAKE_BINARY_DIR}/webrepl)
|
|
||||||
|
|
||||||
# custom output directory for webm + js file
|
# custom output directory for webm + js file
|
||||||
set_target_properties(Luau.Repl.Web PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/webrepl/luau)
|
set_target_properties(Luau.Repl.Web PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/docs/assets/luau)
|
||||||
else()
|
else()
|
||||||
if(LUAU_BUILD_CLI)
|
if(LUAU_BUILD_CLI)
|
||||||
add_executable(Luau.Repl.CLI)
|
add_executable(Luau.Repl.CLI)
|
||||||
|
|
|
@ -25,3 +25,5 @@ pages:
|
||||||
url: /profile
|
url: /profile
|
||||||
- title: Library
|
- title: Library
|
||||||
url: /library
|
url: /library
|
||||||
|
- title: Demo
|
||||||
|
url: /demo
|
||||||
|
|
53
docs/_includes/repl.html
Normal file
53
docs/_includes/repl.html
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<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>
|
7
docs/_pages/demo.md
Normal file
7
docs/_pages/demo.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
permalink: /demo
|
||||||
|
title: Demo
|
||||||
|
toc: true
|
||||||
|
---
|
||||||
|
|
||||||
|
{% include repl.html %}
|
Loading…
Add table
Reference in a new issue