github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/gen/website/wasm/index.html (about)

     1  <html>  
     2      <head>
     3          <meta charset="utf-8"/>
     4          <style>
     5              #term {
     6                  background-color: #eee8d5;
     7                  color: #073642;
     8                  scroll-behavior: auto;
     9                  font-size: 14px;
    10                  width: 120ch;
    11                  height: auto;
    12              }
    13  
    14              .sgr-black   { color: #073642; }
    15              .sgr-red     { color: #dc322f; }
    16              .sgr-green   { color: #859900; }
    17              .sgr-yellow  { color: #b58900; }
    18              .sgr-blue    { color: #268bd2; }
    19              .sgr-magenta { color: #d33682; }
    20              .sgr-cyan    { color: #2aa198; }
    21              .sgr-white   { color: #eee8d5; }
    22  
    23              .sgr-bold    { font-weight: bold; }
    24              .sgr-italic  { font-style: italic; }
    25              .sgr-underscore { text-decoration: underline; }
    26              .sgr-blink {
    27                  animation: animate 1s linear infinite;
    28                  transform: translate(-50%, -50%);
    29              }
    30              @keyframes animate {
    31                  0%    { opacity: 0;   }
    32                  50%   { opacity: 0.7; }
    33                  100%  { opacity: 0;   }
    34              }
    35          </style>
    36      </head>
    37      <body>
    38          <h1>Murex WASM Build</h1>
    39          <pre id="term" contenteditable="">
    40  Loading....
    41  (this might take a few minutes on slower connections)
    42          </pre>
    43          <!--<input id="block" name="block" type="string" />
    44          <input id="button" type="submit" name="button" value="Run" onclick="shellExec(block.value)"/>
    45          -->
    46          <script src="wasm_exec.js"></script>
    47          <script>
    48              document.getElementById("term").addEventListener("keypress", function(event) {
    49                  event.preventDefault();
    50                  var x = event.charCode
    51                  var y = String.fromCharCode(x); 
    52                  //console.log(`${x} -- ${y} has been pressed`);
    53                  shellKeyPress(y);
    54              });
    55  
    56              const go = new Go();
    57              WebAssembly.instantiateStreaming(fetch("murex.wasm"), go.importObject).then((result) => {
    58                  go.run(result.instance);
    59                  shellStart();
    60              });
    61  
    62              async function shellExec(cmd) {
    63                  try {
    64                      console.log(await wasmShellExec(cmd));
    65                  } catch (err) {
    66                      console.error('Caught exception', err);
    67                  };
    68              };
    69  
    70              async function shellStart(cmd) {
    71                  try {
    72                      console.log(await wasmShellStart(cmd));
    73                  } catch (err) {
    74                      console.error('Caught exception', err);
    75                  };
    76              };
    77  
    78              async function shellKeyPress(stdin) {
    79                  try {
    80                      console.log(await wasmKeyPress(stdin));
    81                  } catch (err) {
    82                      console.error('Caught exception', err);
    83                  };
    84              };
    85          </script>
    86     </body>
    87  </html>