diff options
Diffstat (limited to 'web/static')
-rw-r--r-- | web/static/dartboat.js | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/web/static/dartboat.js b/web/static/dartboat.js index 2e9429c..662fd3f 100644 --- a/web/static/dartboat.js +++ b/web/static/dartboat.js @@ -1,16 +1,9 @@ -let match_state, user_rem; +let user_rem; let oi_timeout; let prompt_handler; -let delay_ms = 1000; const POINT_CLASSES = [180, 140, 100, 60, 40, 20, 1, 0]; -function stcall(f, ret_type, arg_types, args) { - return Module.ccall(f, ret_type, - arg_types ? ['number'].concat(arg_types) : ['number'], - args ? [match_state].concat(args) : [match_state]); -} - let prompt_handler_visit = { append(val) { let elem = document.getElementById('prompt'); @@ -40,14 +33,7 @@ let prompt_handler_visit = { if (pts_is_rem) pts = user_rem - pts; - if (!stcall('user_visit', 'number', ['number'], [pts])) - return; - - clearMatchLog(); - stcall('draw_match'); - - if (!stcall('is_match_over', 'number')) - stcall('boat_visit', 'number', ['number'], [delay_ms]); + Module.ccall('user_visit', 'number', ['number'], [pts]); }, submit_rem() { @@ -77,7 +63,7 @@ let prompt_handler_num_darts = { if (!val) return; promptClear(); - stcall('resp_numdarts', null, ['number'], [val]); + Module.ccall('resp_numdarts', null, ['number'], [val]); } } @@ -133,10 +119,7 @@ function clearMatchLog() { } function initMatch() { - if (match_state) - stcall('free_match'); - //updateDelay(delay_ms); - match_state = stcall('start_match', 'number'); + Module.ccall('start_match'); } function oi() { @@ -224,14 +207,17 @@ function setPromptText(ptr) { function scheduleBoatThrowing(pts, ptr, delay_ms) { // ptr to c string must be copied before returning let str = UTF8ToString(ptr); - setTimeout(function() { - stcall('draw_boat_throwing', null, ['number', 'string'], [pts, str]) }, - delay_ms); + setTimeout( + function() { Module.ccall('draw_boat_throwing', null, + ['number', 'string'], [pts, str]) }, + delay_ms); } function scheduleEndBoatThrowing(rem, avg, delay_ms) { - setTimeout(function() { - stcall('end_boat_throwing', null, ['number', 'number'], [rem, avg]) }, delay_ms); + setTimeout( + function() { Module.ccall('end_boat_throwing', null, + ['number', 'number'], [rem, avg]) }, + delay_ms); } function drawVisit(visit_no, u_pts, u_rem, b_pts, b_rem, b_darts) { @@ -261,7 +247,7 @@ function updateStdev(val) { } function delayChanged(val) { - delay_ms = val; + Module.ccall('change_delay', null, ['number'], [val]); } function updateDelay(val) { |