diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-03-20 15:30:12 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-03-20 15:30:28 -0400 |
| commit | f8d53f2a981bcbb93f53b11f21563ca477b7915a (patch) | |
| tree | 5651f6c8a911fcd908f8298d69ccf50f2f6b3adf | |
| parent | e8174e823c598b6bfa28cc4b39d582dfea3acc81 (diff) | |
Ignore the REPL URL fragment if it doesn't have code=
| -rw-r--r-- | docs/repl.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/docs/repl.js b/docs/repl.js index b65bb6e5..6b6e1332 100644 --- a/docs/repl.js +++ b/docs/repl.js @@ -147,15 +147,17 @@ if (doc.demo) doc.demo.onclick = () => { } if (location.hash) { - let code='', run=1, ee=0; + let code, run=1, ee=0; location.hash.slice(1).split('&').map(s => { if (s.slice(0,5)==='code=') code=s.slice(5); if (s.slice(0,5)==='norun') run=0; if (s.slice(0,7)==='explain') ee=1; }); - let b=atob(code); - b=new Uint8Array([...b].map(c=>c.charCodeAt(0))); - setcount(doc.code.value = (new TextDecoder()).decode(b)); - if (ee && doc.doexplain) doc.doexplain.onclick(); - if (run) repl(); + if (code!==undefined) { + let b=atob(code); + b=new Uint8Array([...b].map(c=>c.charCodeAt(0))); + setcount(doc.code.value = (new TextDecoder()).decode(b)); + if (ee && doc.doexplain) doc.doexplain.onclick(); + if (run) repl(); + } } |
