summaryrefslogtreecommitdiffstats
path: root/main.mjs
diff options
context:
space:
mode:
authorBrian Cully <bjc@spork.org>2025-08-07 14:16:43 -0400
committerBrian Cully <bjc@spork.org>2025-08-19 11:48:43 -0400
commit2eecdb1a4bae0fbced05f4c375cd6126929fb1fb (patch)
treeb39ce956c5114cb2d1d14c6a7f09eb857e63d84c /main.mjs
downloadautomathon-2eecdb1a4bae0fbced05f4c375cd6126929fb1fb.tar.gz
automathon-2eecdb1a4bae0fbced05f4c375cd6126929fb1fb.zip
parser now emits list of words and hashmap of string→index
wordlist is just a vector of bytecode entries. to associate a word to an entry in the wordlist, use the word catalog to look up by name.
Diffstat (limited to 'main.mjs')
-rw-r--r--main.mjs22
1 files changed, 22 insertions, 0 deletions
diff --git a/main.mjs b/main.mjs
new file mode 100644
index 0000000..63f277e
--- /dev/null
+++ b/main.mjs
@@ -0,0 +1,22 @@
+import init from './pkg/automathon.js';
+
+async function loaded() {
+ console.debug('run');
+ const mod = await init();
+ console.debug('init done', mod);
+
+ window.calculate = _ => {
+ console.debug('calc');
+ const inp1 = document.getElementById('number-input1').value;
+ const inp2 = document.getElementById('number-input2').value;
+ const res = mod.add(parseInt(inp1), parseInt(inp2));
+ document.getElementById('result').textContent = res;
+ }
+
+ window.testalert = _ => {
+ console.debug('testalert');
+ mod.run();
+ }
+}
+
+document.addEventListener('DOMContentLoaded', loaded);