diff options
| author | brian cully <bjc@spork.org> | 2025-12-27 14:33:52 -0500 |
|---|---|---|
| committer | brian cully <bjc@spork.org> | 2025-12-27 14:33:52 -0500 |
| commit | c182d8179ddd382543b7e56f46e78bf6a6724b2a (patch) | |
| tree | 0bc2f2e45ec99711110b4d6b463e472312c6224c /site/main.mjs | |
| parent | b35fd970e93a5bb4290134f842ac4f7e00a177b2 (diff) | |
| download | polyring-c182d8179ddd382543b7e56f46e78bf6a6724b2a.tar.gz polyring-c182d8179ddd382543b7e56f46e78bf6a6724b2a.zip | |
dispatch wasm/pure based on query part of url
Diffstat (limited to 'site/main.mjs')
| -rw-r--r-- | site/main.mjs | 29 |
1 files changed, 29 insertions, 0 deletions
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); |
