emscripten-tutorial

How to build an increasingly complex C/C++ codebase to WebAssembly
git clone https://git.tronto.net/emscripten-tutorial
Download | Log | Files | Refs | README

script.mjs (518B)


      1 import Primes from "./build/primes.mjs";
      2 
      3 var primes = await Primes();
      4 
      5 var aInput = document.getElementById("aInput");
      6 var bInput = document.getElementById("bInput");
      7 var button = document.getElementById("goButton");
      8 var resultText = document.getElementById("resultText");
      9 
     10 button.addEventListener("click", () => {
     11 	var a = Number(aInput.value);
     12 	var b = Number(bInput.value);
     13 	const count = primes._primes_in_range(a, b);
     14 	resultText.innerText = "There are " + count + " primes between " +
     15 	    a + " and " + b;
     16 });