aboutsummaryrefslogtreecommitdiff
path: root/06_storage/script.mjs
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-06-06 09:13:54 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-06-06 09:13:54 +0200
commitab0db69a7b11ba1a9dc52d50c94e9e321b70ebf0 (patch)
tree76be6a8b1596ea1e74dbf7085b85214c2c83e69a /06_storage/script.mjs
parent961c3470d7e9bdf5efbe0509f586be75d7052d8b (diff)
downloademscripten-tutorial-ab0db69a7b11ba1a9dc52d50c94e9e321b70ebf0.tar.gz
emscripten-tutorial-ab0db69a7b11ba1a9dc52d50c94e9e321b70ebf0.zip
Added example 6
Diffstat (limited to '')
-rw-r--r--06_storage/script.mjs20
1 files changed, 20 insertions, 0 deletions
diff --git a/06_storage/script.mjs b/06_storage/script.mjs
new file mode 100644
index 0000000..1238371
--- /dev/null
+++ b/06_storage/script.mjs
@@ -0,0 +1,20 @@
1var aInput = document.getElementById("aInput");
2var bInput = document.getElementById("bInput");
3var button = document.getElementById("goButton");
4var resultText = document.getElementById("resultText");
5
6var worker = new Worker("./worker.mjs", { type: "module" });
7
8button.addEventListener("click", () => worker.postMessage({
9 a: Number(aInput.value),
10 b: Number(bInput.value)
11}));
12
13worker.onmessage = (e) => {
14 if (e.data.type == "response")
15 resultText.innerText = e.data.message;
16 else if (e.data.type == "readySignal") {
17 button.disabled = false;
18 button.innerText = "Compute"
19 }
20};

Generated with cgit - Back to sebastiano.tronto.net