add js repl

This commit is contained in:
ed 2021-08-30 01:09:27 +02:00
parent f5712d9f25
commit fc49cb1e67
10 changed files with 61 additions and 1 deletions

View file

@ -204,6 +204,9 @@ a, #files tbody div a:last-child {
color: #f4c; color: #f4c;
border-bottom: 1px solid rgba(255,68,204,0.6); border-bottom: 1px solid rgba(255,68,204,0.6);
} }
#repl {
padding: .33em;
}
#files tbody a.play { #files tbody a.play {
color: #e70; color: #e70;
padding: .2em; padding: .2em;

View file

@ -114,6 +114,8 @@
<h2><a href="/?h">control-panel</a></h2> <h2><a href="/?h">control-panel</a></h2>
<a href="#" id="repl">π</a>
</div> </div>
{%- if srv_info %} {%- if srv_info %}

View file

@ -8,6 +8,14 @@ html, body {
font-family: sans-serif; font-family: sans-serif;
line-height: 1.5em; line-height: 1.5em;
} }
#repl {
position: absolute;
top: 0;
right: .2em;
border: none;
color: inherit;
background: none;
}
#mtw { #mtw {
display: none; display: none;
} }
@ -506,6 +514,9 @@ blink {
border-bottom: .07em solid #4ac; border-bottom: .07em solid #4ac;
padding: 0 .3em; padding: 0 .3em;
} }
#repl {
display: none;
}
#toc>ul { #toc>ul {
border-left: .1em solid #84c4dd; border-left: .1em solid #84c4dd;
} }

View file

@ -45,6 +45,7 @@
</div> </div>
<div id="mp"></div> <div id="mp"></div>
</div> </div>
<a href="#" id="repl">π</a>
{%- if edit %} {%- if edit %}
<div id="helpbox"> <div id="helpbox">

View file

@ -22,6 +22,15 @@ html, body {
bottom: auto; bottom: auto;
top: 1.4em; top: 1.4em;
} }
#repl {
position: absolute;
top: 0;
right: .5em;
border: none;
color: inherit;
background: none;
text-decoration: none;
}
#mn { #mn {
font-weight: normal; font-weight: normal;
margin: 1.3em 0 .7em 1em; margin: 1.3em 0 .7em 1em;

View file

@ -21,6 +21,7 @@
<textarea id="mt" style="display:none" autocomplete="off">{{ md }}</textarea> <textarea id="mt" style="display:none" autocomplete="off">{{ md }}</textarea>
</div> </div>
</div> </div>
<a href="#" id="repl">π</a>
<script> <script>
var last_modified = {{ lastmod }}; var last_modified = {{ lastmod }};

View file

@ -29,6 +29,11 @@ a {
border-radius: .2em; border-radius: .2em;
padding: .2em .8em; padding: .2em .8em;
} }
#repl {
background: none;
color: inherit;
padding: 0;
}
table { table {
border-collapse: collapse; border-collapse: collapse;
} }

View file

@ -7,6 +7,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=0.8"> <meta name="viewport" content="width=device-width, initial-scale=0.8">
<link rel="stylesheet" media="screen" href="/.cpr/splash.css?_={{ ts }}"> <link rel="stylesheet" media="screen" href="/.cpr/splash.css?_={{ ts }}">
<link rel="stylesheet" media="screen" href="/.cpr/ui.css?_={{ ts }}">
</head> </head>
<body> <body>
@ -66,11 +67,13 @@
</form> </form>
</ul> </ul>
</div> </div>
<a href="#" id="repl">π</a>
<script> <script>
if (localStorage.getItem('lightmode') != 1) if (localStorage.getItem('lightmode') != 1)
document.documentElement.setAttribute("class", "dark"); document.documentElement.setAttribute("class", "dark");
</script> </script>
<script src="/.cpr/util.js?_={{ ts }}"></script>
</body> </body>
</html> </html>

View file

@ -107,6 +107,7 @@ html {
padding: 1.5em 2em; padding: 1.5em 2em;
border-width: .5em 0; border-width: .5em 0;
} }
#modalc code,
#tt code { #tt code {
background: #3c3c3c; background: #3c3c3c;
padding: .1em .3em; padding: .1em .3em;
@ -125,6 +126,7 @@ html.light #tt,
html.light #toast { html.light #toast {
box-shadow: 0 .3em 1em rgba(0,0,0,0.4); box-shadow: 0 .3em 1em rgba(0,0,0,0.4);
} }
#modalc code,
html.light #tt code { html.light #tt code {
background: #060; background: #060;
color: #fff; color: #fff;
@ -207,6 +209,8 @@ html.light #tt em {
} }
#modali { #modali {
display: block; display: block;
background: #fff;
color: #000;
width: calc(100% - 1.25em); width: calc(100% - 1.25em);
margin: 1em -.1em 0 -.1em; margin: 1em -.1em 0 -.1em;
padding: .5em; padding: .5em;

View file

@ -892,3 +892,24 @@ function winpopup(txt) {
body: 'msg=' + uricom_enc(Date.now() + ', ' + txt) body: 'msg=' + uricom_enc(Date.now() + ', ' + txt)
}); });
} }
function repl(e) {
ev(e);
modal.prompt('js repl (prefix with <code>,</code> to allow raise)', 'var v=Object.keys(localStorage); v.sort(); JSON.stringify(v)', function (cmd) {
if (!cmd)
return toast.inf(3, 'eval aborted');
if (cmd.startsWith(','))
return modal.alert(esc(eval(cmd.slice(1)) + ''))
try {
modal.alert(esc(eval(cmd) + ''));
}
catch (ex) {
modal.alert('<h6>exception</h6>' + esc(ex + ''));
}
});
}
if (ebi('repl'))
ebi('repl').onclick = repl;