Browse Source

Improve demo (#136)

* demo: evaluate on input instead of on button press

* demo: use `monospace` font

* demo: make the input blank initially (remove space)
pull/145/head
WofWca 5 years ago committed by Jason Williams
parent
commit
a48b9b8aab
  1. 2
      index.html
  2. 8
      index.js

2
index.html

@ -28,6 +28,7 @@
.demo__repl { .demo__repl {
display: flex; display: flex;
font-family: monospace;
} }
.output { .output {
@ -64,7 +65,6 @@
<textarea class="form-control textbox"></textarea> <textarea class="form-control textbox"></textarea>
<p class="output"></p> <p class="output"></p>
</div> </div>
<button type="buttont" class="btn btn-primary">Evaluate</button>
</div> </div>
</body> </body>

8
index.js

@ -6,12 +6,12 @@ const rust = import("./pkg");
rust.then(m => { rust.then(m => {
window.evaluate = m.evaluate; window.evaluate = m.evaluate;
let button = document.querySelector("button"); let textarea = document.querySelector("textarea");
button.addEventListener("click", clickHandler); textarea.addEventListener("input", inputHandler);
}); });
function clickHandler(evt) { function inputHandler(evt) {
let text = document.querySelector("textarea").value; let text = evt.target.value;
let p = document.querySelector("p.output"); let p = document.querySelector("p.output");
let t0 = performance.now(); let t0 = performance.now();
let result = window.evaluate(text); let result = window.evaluate(text);

Loading…
Cancel
Save