summaryrefslogtreecommitdiff
path: root/web/static/dartboat.js
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-26 23:29:00 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-26 23:29:00 -0700
commita273e90b445ec82a04f92187adfe610cd0703dba (patch)
treeb018db0f04b99b5aa62201e1d947166e6e82cda3 /web/static/dartboat.js
parent44384cf8e219b40d8f204d2f8714cacc3690070a (diff)
downloaddartboat-a273e90b445ec82a04f92187adfe610cd0703dba.tar.gz
dartboat-a273e90b445ec82a04f92187adfe610cd0703dba.tar.xz
web: rid HTML of inline JS
Maybe I'll change this to use targeted event listeners when I'm not lazy.
Diffstat (limited to 'web/static/dartboat.js')
-rw-r--r--web/static/dartboat.js27
1 files changed, 21 insertions, 6 deletions
diff --git a/web/static/dartboat.js b/web/static/dartboat.js
index 428ff85..285a98e 100644
--- a/web/static/dartboat.js
+++ b/web/static/dartboat.js
@@ -54,8 +54,8 @@ function promptMsgR(p) {
document.getElementById('prompt-msg-r').textContent = UTF8ToString(p);
}
-function promptHandle(action, data) {
- Module.ccall('prompt_handle', null, ['string', 'string'], [action, data]);
+function promptHandle(command, data) {
+ Module.ccall('prompt_handle', null, ['string', 'string'], [command, data]);
}
function setKeypad(keypad) {
@@ -169,12 +169,27 @@ function readOpts() {
setStdev(val, false);
}
-function modal(id) {
- document.getElementById(id).style.display = 'block';
-}
+document.addEventListener('click', e => {
+ const modal = e.target.dataset.modal;
+ if (modal)
+ document.getElementById(modal).style.display = 'block';
+
+ if (e.target.classList.contains('modal'))
+ e.target.style.display = 'none';
+});
document.addEventListener('click', e => {
- if (e.target.classList.contains('modal')) e.target.style.display = 'none';
+ const command = e.target.dataset.command;
+ if (command)
+ command.split(';').forEach(x => promptHandle(...x.split(':', 2)));
+});
+
+document.addEventListener('change', e => {
+ const setting = e.target.dataset.setting;
+ if (setting === 'delay')
+ setDelay(e.target.value);
+ else if (setting === 'stdev')
+ setStdev(e.target.value);
});
document.addEventListener('keydown', e => {