index.html 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script type="module">
  5. import init, {matzo_run} from "./matzo_web.js";
  6. const sources = %SOURCES%;
  7. window.onload = () => {
  8. const run = document.getElementById('run');
  9. const src = document.getElementById('src');
  10. const output = document.getElementById('output');
  11. const examples = document.getElementById('examples');
  12. examples.onchange = () => {
  13. src.value = sources[examples.value];
  14. };
  15. init()
  16. .then(() => {
  17. run.onclick = () => {
  18. let result = matzo_run(src.value);
  19. output.innerHTML = result;
  20. }
  21. });
  22. };
  23. </script>
  24. <style type="text/css">
  25. body, html {
  26. height: 100%;
  27. margin: 0em;
  28. }
  29. .all {
  30. margin-left: auto;
  31. margin-right: auto;
  32. height: 100%;
  33. display: flex;
  34. }
  35. .all > div {
  36. margin: 1em;
  37. padding: 1em;
  38. border: 1px solid;
  39. width: 50%;
  40. height: 90%;
  41. }
  42. #output {
  43. font-family: "Fira Mono";
  44. white-space: pre-wrap;
  45. }
  46. </style>
  47. </head>
  48. <body>
  49. <div class="all">
  50. <div class="panel">
  51. <select id="examples">
  52. <option value="hello">hello.matzo</option>
  53. %EXAMPLES%
  54. </select><br/>
  55. <textarea id="src" cols="80" rows="30">puts "hello, world!";</textarea><br/>
  56. <input type="submit" id="run" value="Run" />
  57. </div>
  58. <div>
  59. <pre id="output"></pre>
  60. </div>
  61. </div>
  62. </body>
  63. </html>