From 5dce742cc9593dce4c07233d15e11e1320ef6d13 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Wed, 27 Apr 2022 00:53:05 -0700 Subject: web: handle race condition on load This is incredibly unlikely to ever matter unless your browser is a potato. --- web/static/dartboat.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'web/static') 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'); +} -- cgit v1.2.3-70-g09d2