diff options
Diffstat (limited to '04_no_block/script.mjs')
| -rw-r--r-- | 04_no_block/script.mjs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/04_no_block/script.mjs b/04_no_block/script.mjs new file mode 100644 index 0000000..b9c27ea --- /dev/null +++ b/04_no_block/script.mjs | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | var aInput = document.getElementById("aInput"); | ||
| 2 | var bInput = document.getElementById("bInput"); | ||
| 3 | var button = document.getElementById("goButton"); | ||
| 4 | var resultText = document.getElementById("resultText"); | ||
| 5 | |||
| 6 | var worker = new Worker("./worker.mjs", { type: "module" }); | ||
| 7 | |||
| 8 | button.addEventListener("click", () => worker.postMessage({ | ||
| 9 | a: Number(aInput.value), | ||
| 10 | b: Number(bInput.value) | ||
| 11 | })); | ||
| 12 | |||
| 13 | worker.onmessage = (e) => resultText.innerText = "There are " + | ||
| 14 | e.data.result + " primes between " + e.data.a + " and " + e.data.b; | ||
