diff options
Diffstat (limited to 'web/static/dartboat.js')
-rw-r--r-- | web/static/dartboat.js | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/web/static/dartboat.js b/web/static/dartboat.js index 292c50d..2a26a0c 100644 --- a/web/static/dartboat.js +++ b/web/static/dartboat.js @@ -45,9 +45,9 @@ let prompt_handlers = { }, submit_rem() { - let pts = _promptGetAndClear(); - if (pts) - Module.ccall('user_visit', 'number', ['number'], [user_rem - pts]); + let rem = _promptGetAndClear(); + if (rem) + Module.ccall('user_visit_to_rem', 'number', ['number'], [rem]); } }, num_darts: { @@ -127,22 +127,12 @@ function clearOi() { } } -let user_rem; -function updateUserRem(rem) { - user_rem = rem; - updateUserStateRem(rem); +function updateUserStateRem(ptr) { + document.getElementById('p1-rem').textContent = UTF8ToString(ptr); } -function updateUserStateRem(rem) { - let elem = document.getElementById('p1-rem'); - elem.textContent = rem < 0 || rem == 1 ? 'BUST' : rem; - Module.ccall('get_suggested', null, ['number', 'number'], [rem, 1]); -} - -function updateBoatStateRem(rem) { - let elem = document.getElementById('p2-rem'); - elem.textContent = rem < 0 || rem == 1 ? 'BUST' : rem; - Module.ccall('get_suggested', null, ['number', 'number'], [rem, 2]); +function updateBoatStateRem(ptr) { + document.getElementById('p2-rem').textContent = UTF8ToString(ptr); } function updateUserName(p) { @@ -182,10 +172,7 @@ function promptSugg(p) { } function promptUpdateRem() { - let elem = document.getElementById('p1-rem'); - let pts = _promptGet(); - - updateUserStateRem(pts ? user_rem - pts : user_rem); + Module.ccall('update_user_rem_from_pts', null, ['number'], [_promptGet()]); } function setUserActive() { |