From 56bdba513ab912910f4bb703092f7e02b3411b70 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Sat, 7 May 2022 09:23:40 -0700 Subject: web: allow controls side to be chosen by user --- web/static/dartboat.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'web/static/dartboat.js') diff --git a/web/static/dartboat.js b/web/static/dartboat.js index e09e8f6..8a1b19f 100644 --- a/web/static/dartboat.js +++ b/web/static/dartboat.js @@ -112,6 +112,11 @@ function boatAfloat() { _init(); } +function flipControls() { + const enabled = $('#main').classList.toggle('right-controls'); + $('#flip-controls-button').textContent = enabled ? '\u2190' : '\u2192'; +} + document.addEventListener('DOMContentLoaded', () => { let f; @@ -119,9 +124,11 @@ document.addEventListener('DOMContentLoaded', () => { promptHandle(...x.split(':', 2))); $$('[data-command]').forEach(x => x.addEventListener('click', f)); - f = e => _set_opt(toCString(e.target.dataset.setting), + f = e => _set_opt(toCString(e.target.dataset.opt), toCString(e.target.value)); - $$('[data-setting]').forEach(x => x.addEventListener('change', f)); + $$('[data-opt]').forEach(x => x.addEventListener('change', f)); + + $('#flip-controls-button').addEventListener('click', flipControls); f = e => $(`#${e.target.dataset.modal}`).style.display = 'block'; $$('[data-modal]').forEach(x => x.addEventListener('click', f)); -- cgit v1.2.3-70-g09d2