~fd/cane-lang

4d96d419ea961f0a64bc395f57b1c5d9a15b9385 — Ersei Saggi 10 months ago db2d0ab
Improve web playground experience
1 files changed, 18 insertions(+), 13 deletions(-)

M cane-wasm/index.html
M cane-wasm/index.html => cane-wasm/index.html +18 -13
@@ 48,7 48,7 @@ arg1 arg2 arg3 (space separated)</textarea
      target="_blank"
      >Demos</a
    >
    <pre id="output">Output</pre>
    <pre id="output"><noscript>Enable Javascript to continue.</noscript></pre>
    <script type="module">
      // https://stackoverflow.com/a/47880734
      const supported = (() => {


@@ 72,25 72,30 @@ arg1 arg2 arg3 (space separated)</textarea
      window.writeOut = function writeOut(text) {
        document.getElementById('output').innerText += text
      }

      import init, { interpreter } from './pkg/cane_wasm.js'

      if (!supported) {
        document.getElementById('output').innerText = ''
        writeOut(
          'WebAssembly not supported! This playground will not function.'
        )
      }

      import init, { interpreter } from './pkg/cane_wasm.js'

      init()
      } else {
        document.getElementById('output').innerText = ''
        writeOut('Loading...')
        init()

      document.getElementById('run').onclick = function () {
        document.getElementById('run').onclick = function () {
          document.getElementById('output').innerText = ''
          init().then(() => {
            interpreter(
              document.getElementById('code_input').value,
              document.getElementById('args_input').value
            )
          })
        }
        document.getElementById('output').innerText = ''
        init().then(() => {
          interpreter(
            document.getElementById('code_input').value,
            document.getElementById('args_input').value
          )
        })
        writeOut('Ready.')
      }
    </script>
  </body>