From e297ac65f8f0cde103880c73d0c92ad3cb50f161 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Tue, 3 May 2022 13:21:24 -0700 Subject: web: more use of generic JS functions --- web/static/dartboat.js | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'web/static/dartboat.js') diff --git a/web/static/dartboat.js b/web/static/dartboat.js index b420543..99513e2 100644 --- a/web/static/dartboat.js +++ b/web/static/dartboat.js @@ -53,6 +53,13 @@ function elemToggleClass(sel, c) { $(UTF8ToString(sel)).classList.toggle(UTF8ToString(c)); } +function elemSetUniqClass(sel, c, sel_set) { + selstr = sel && UTF8ToString(sel); + cstr = UTF8ToString(c); + $$(UTF8ToString(sel_set)).forEach(e => + e.classList[sel && e.matches(selstr) ? 'add' : 'remove'](cstr)); +} + function promptHandle(command, data) { const str_c = toCString(command); const str_d = data && toCString(data); @@ -62,25 +69,6 @@ function promptHandle(command, data) { if (str_d) _free(str_d); } -function setKeypad(keypad) { - const keypad_id = `keypad-${UTF8ToString(keypad)}`; - $$('.keypad').forEach(e => - e.style.display = e.id === keypad_id ? '' : 'none'); -} - -function setPlayerActive(n) { - $$('[id$=-info]').forEach(e => - e.classList[n && e.id == `p${n}-info` ? 'add' : 'remove']('active')); -} - -function showPlayerInfo(n) { - $(`#p${n}-info-inner`).style.visibility = 'visible'; -} - -function hidePlayerInfo(n) { - $(`#p${n}-info-inner`).style.visibility = 'hidden'; -} - const POINT_CLASSES = [180, 140, 100, 60, 40, 20, 0]; function drawVisit(visit_no, p1_pts, p1_rem, p2_pts, p2_rem, p2_darts) { const e = $('#visits'); -- cgit v1.2.3-70-g09d2