summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web/dartboat_wasm.c7
-rw-r--r--web/static/dartboat.js8
2 files changed, 14 insertions, 1 deletions
diff --git a/web/dartboat_wasm.c b/web/dartboat_wasm.c
index 7c06849..c3091e9 100644
--- a/web/dartboat_wasm.c
+++ b/web/dartboat_wasm.c
@@ -628,9 +628,14 @@ EMSCRIPTEN_KEEPALIVE void prompt_handle(char *command, char *data)
prompt_handle_undo();
}
-int main()
+EMSCRIPTEN_KEEPALIVE void init()
{
init_boat();
set_prompt_mode(PM_VISIT);
handle_next();
}
+
+int main()
+{
+ EM_ASM(boatReady());
+}
diff --git a/web/static/dartboat.js b/web/static/dartboat.js
index 285a98e..06d9d10 100644
--- a/web/static/dartboat.js
+++ b/web/static/dartboat.js
@@ -209,3 +209,11 @@ document.addEventListener('keydown', e => {
else if (e.key == 'u')
promptHandle('undo');
});
+
+function boatReady() {
+ if (document.readyState === 'loading')
+ document.addEventListener('DOMContentLoaded', () =>
+ Module.ccall('init'));
+ else
+ Module.ccall('init');
+}