|
34 | 34 | <h1>Schemascii Playground</h1> |
35 | 35 | <div class="flex row"> |
36 | 36 | <div class="flex column"> |
37 | | - <div class="flex row"> |
38 | | - <p style="flex: 3">Schemascii Source</p> |
39 | | - <button id="render" style="flex: 1">Render</button> |
40 | | - </div><textarea id="schemascii"></textarea> |
| 37 | + <p>Schemascii Source</p><textarea id="schemascii"></textarea> |
41 | 38 | </div> |
42 | 39 | <div class="flex column"> |
43 | 40 | <p>CSS</p><textarea id="css"></textarea> |
@@ -89,15 +86,19 @@ <h1>Schemascii Playground</h1> |
89 | 86 | css.addEventListener("input", () => { |
90 | 87 | style_elem.innerHTML = css.value; |
91 | 88 | }); |
92 | | - render_button.addEventListener("click", async () => { |
93 | | - console.textContent = ""; |
94 | | - errors.textContent = ""; |
95 | | - try { |
96 | | - output.innerHTML = await schemascii.render("playground", source.value); |
97 | | - } catch (e) { |
98 | | - error(`\nJS Error:\n${e.stack}\n`); |
99 | | - throw e; |
100 | | - } |
| 89 | + var timeout = null; |
| 90 | + source.addEventListener("input", () => { |
| 91 | + if (timeout) clearTimeout(timeout); |
| 92 | + setTimeout(async () => { |
| 93 | + console.textContent = ""; |
| 94 | + errors.textContent = ""; |
| 95 | + try { |
| 96 | + output.innerHTML = await schemascii.render("playground", source.value); |
| 97 | + } catch (e) { |
| 98 | + error(`\nJS Error:\n${e.stack}\n`); |
| 99 | + throw e; |
| 100 | + } |
| 101 | + }, 500); |
101 | 102 | }); |
102 | 103 | } |
103 | 104 | main(); |
|
0 commit comments