-
Notifications
You must be signed in to change notification settings - Fork 0
/
lua.html
81 lines (81 loc) · 2.65 KB
/
lua.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<html><head>
<meta charset="UTF-8" />
<title>Lua</title>
<link rel="stylesheet" href="/css/khak.css" type="text/css" id="theme"></link>
<link rel="icon" href='/media/NPHotChoc.svg.png'></link>
<script src="lib/fengari-web.js" type="text/javascript"></script>
</head>
<body >
<div class="gray notes">
Lua Repl
<image src="/media/moon.svg" id="themech"
width="30" height="30" >
</image> <!-- </button> -->
<script type="text/javascript" src="/js/theme.js">
</script>
<br>
</div>
<div class="fg">
<blockquote style="text-align: left;">
<pre id="out" style="max-height: 50%; overflow-y: auto;"><br>
Lua5.3, powered by <a href="https://github.com/fengari-lua">Fengari</a><br></pre>
=> <input type="search"
style="width: 500px; font-size: 20pt;
font-family: 'SpiderWireMono';"
id="inp"></input>
</blockquote></div>
<script src="/js/console.js" type="text/javascript"></script>
<script type="application/lua">
print("(prefix with = to see the result)")
js = require("js")
lisp= require("lisp")
</script>
<script type="application/lua">
function tree(obj, maxdepth, before) -- call like tree(var) or tree(var, 4)
before = before or ""; maxdepth = maxdepth or 4
if (maxdepth > 0) then
for key, val in pairs(obj) do
if (type(val) == "string") then
if (val:len() < 20) then
print(before .."-> "..key .. "='" .. val .. "'")
else
print(before .."-> "..key .. "='" .. val:sub(1,15) .. ". . .")
end
elseif (type(val) == "number") then
print(before .."-> "..key .. "= " .. val)
elseif (type(val) == "function") then
print(before .."-> "..key .. "()")
elseif (type(val) == "table") then
if key == "parent" then print(before.."-> ... parent")
elseif key == "_G" then print(before.."-> ... _G")
elseif key == "__index" then print(before.."-> ... __index")
else
print(before .."-> "..key .. ": ")
tree(val, maxdepth-1, " |" .. before)
end
else print(before .. "-> "..key.."=", val)
end
end
else
print(before .." ...")
end
return obj
end
</script>
<script>
myconsole.setinputhandler(
(str)=>{
try{
d=fengari.load(
str.replace(/^=(.*)/,"return ($1)")
)()
if (d != undefined){
myconsole.log(d)
}
} catch(err) {
myconsole.error(err);
}
}
)
</script>
</body></html>