summaryrefslogtreecommitdiff
path: root/web/static/dartboat.js
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-03 13:21:24 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-03 13:22:43 -0700
commite297ac65f8f0cde103880c73d0c92ad3cb50f161 (patch)
treed08677e97ae1a863f1c8eed49dc36560d544d7ca /web/static/dartboat.js
parent9a0f3d15dfaac41657bb549c7e246d2ac81fdf4c (diff)
downloaddartboat-e297ac65f8f0cde103880c73d0c92ad3cb50f161.tar.gz
dartboat-e297ac65f8f0cde103880c73d0c92ad3cb50f161.tar.xz
web: more use of generic JS functions
Diffstat (limited to 'web/static/dartboat.js')
-rw-r--r--web/static/dartboat.js26
1 files changed, 7 insertions, 19 deletions
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');