diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-05-07 09:23:40 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-05-07 09:23:40 -0700 |
commit | 56bdba513ab912910f4bb703092f7e02b3411b70 (patch) | |
tree | be5413b76311c24733461a37fcc4bc50d9c4823e /web/static/dartboat.js | |
parent | 9af8170ab7fe5eea31123835f0632890743dbb48 (diff) | |
download | dartboat-56bdba513ab912910f4bb703092f7e02b3411b70.tar.gz dartboat-56bdba513ab912910f4bb703092f7e02b3411b70.tar.xz |
web: allow controls side to be chosen by user
Diffstat (limited to 'web/static/dartboat.js')
-rw-r--r-- | web/static/dartboat.js | 11 |
1 files changed, 9 insertions, 2 deletions
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)); |