From c182d8179ddd382543b7e56f46e78bf6a6724b2a Mon Sep 17 00:00:00 2001 From: brian cully Date: Sat, 27 Dec 2025 14:33:52 -0500 Subject: dispatch wasm/pure based on query part of url --- site/main.mjs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 site/main.mjs (limited to 'site/main.mjs') diff --git a/site/main.mjs b/site/main.mjs new file mode 100644 index 0000000..1457958 --- /dev/null +++ b/site/main.mjs @@ -0,0 +1,29 @@ +let type = 'pure'; +let alts = ['wasm']; +switch (self.location.search) { +case '?wasm': + type = 'wasm'; + alts = ['pure']; + break; +} +const mod = `./${type}.mjs`; + +document.querySelectorAll('.subst-type').forEach(elt => { + elt.textContent = type; +}); +document.querySelectorAll('.subst-alts').forEach(elt => { + const links = alts.map(t => { + const link = document.createElement('a'); + link.setAttribute('href', `?${t}`); + link.textContent = t; + return link; + }); + links.forEach(l => elt.appendChild(l)); +}); + +async function loaded() { + const x = await import(mod); + await x.default(); +} + +document.addEventListener('DOMContentLoaded', loaded); -- cgit v1.3