diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-06-05 10:13:28 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-06-05 10:13:28 +0200 |
| commit | 73efecca42dbc44200e797e02f8c1e24fcff26ef (patch) | |
| tree | 46969fed9d5c09a4164257dace56a71cad9092ab /04_no_block/script.mjs | |
| parent | 2a8e7aeeef99161b6f0378ac14e297c23ca6227b (diff) | |
| download | emscripten-tutorial-73efecca42dbc44200e797e02f8c1e24fcff26ef.tar.gz emscripten-tutorial-73efecca42dbc44200e797e02f8c1e24fcff26ef.zip | |
Added two more examples
Diffstat (limited to '')
| -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; | ||
