CodePlayground/lua.html

44 lines
1.2 KiB
HTML

<!DOCTYPE html>
<html lang="fr">
<head>
<title>Lua Playground</title>
<meta charset="utf-8" />
<script src="lib/codeflask.min.js"></script>
<script src="lib/prism-lua.min.js"></script>
<script src="lib/fengari-web.js"></script>
<link rel="stylesheet" href="assets/css/main.css" type="text/css" />
</head>
<body>
<header>
<h1>Lua Playground</h1>
</header>
<div id="container">
<div id="codeContainer"><div id="code"></div></div><!--
--><div id="console">
</div>
<input type="button" onclick="example()" value="Exemple" id="exBtn" /><!--
--><input type="button" onclick="run()" value="Exécuter !" id="runBtn" /><!--
--><input type="button" onclick="clearCode()" value="Effacer" id="clearBtn" />
</div>
<footer>
Romain de Laage - CC0
</footer>
<script src="assets/js/editor.js"></script>
<script>
const flask = getEditor("#code", "lua")
function run() {
fengari.load(flask.getCode())()
}
function example() {
flask.updateCode("function foo(n)\n for i = 0, n, 1 do\n print('passe ' .. tostring(i))\n end\n return n*n\nend\n\nprint(foo(5))")
}
function clearCode() {
flask.updateCode("")
}
</script>
</body>
</html>