From 73efecca42dbc44200e797e02f8c1e24fcff26ef Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 5 Jun 2025 10:13:28 +0200 Subject: Added two more examples --- 04_no_block/script.mjs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 04_no_block/script.mjs (limited to '04_no_block/script.mjs') 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 @@ +var aInput = document.getElementById("aInput"); +var bInput = document.getElementById("bInput"); +var button = document.getElementById("goButton"); +var resultText = document.getElementById("resultText"); + +var worker = new Worker("./worker.mjs", { type: "module" }); + +button.addEventListener("click", () => worker.postMessage({ + a: Number(aInput.value), + b: Number(bInput.value) +})); + +worker.onmessage = (e) => resultText.innerText = "There are " + + e.data.result + " primes between " + e.data.a + " and " + e.data.b; -- cgit v1.3