diff options
Diffstat (limited to 'demos/lua.html')
-rw-r--r-- | demos/lua.html | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/demos/lua.html b/demos/lua.html new file mode 100644 index 00000000..c06528a7 --- /dev/null +++ b/demos/lua.html @@ -0,0 +1,53 @@ +<html> +<head> + <title> + Emscripten: Lua + </title> + <script src="lua.js"></script> + <script> + // print function which the Lua engine will call + function print(text) { + document.getElementById('output').innerHTML += text + '<br>'; + printed = true; + } + + function execute(text) { + printed = false; + + raw_argv[8] = Pointer_make(intArrayFromString(text), 0, ALLOC_STATIC); // leak! + argv = Pointer_make(raw_argv, null); + + __Z7runargsP9lua_StatePPci(GLOBAL_L, argv, argc) + + if (!printed) { + print('<small><i>(no output)</i></small>'); + } + } + + function doRun() { + args = ['-e', '']; + run(args); + } + + </script> +</head> +<body onload="doRun(); document.getElementById('the_input').focus()"> + <p> + This is the <a href="http://www.lua.org/">Lua</a> interpreter, compiled from C to JavaScript using <a href="http://emscripten.org">Emscripten</a>, + running in your browser (without any plugins). + </p> + <p> + Most stuff should work, please report bugs if you find them! + </p> + <hr> + <!-- Call Lua's execution function --> + <form onsubmit="execute(the_input.value); the_input.value = ''; return false"> + <b>Enter some Lua</b>: + <input type="text" id="the_input"> + <input type="submit" value="execute"> + </form> + <hr> + <div id="output" style="font-family: Courier New,Courier,monospace;"></div> +</body> +</html> + |