diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-23 05:30:47 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-23 05:32:16 -0700 |
commit | 63d17a12c2a894944ab3760e9b5f3dbf6acb95b5 (patch) | |
tree | 35530ee42160e0b4dd8b0333630846501f88a4c6 /web | |
parent | 71b2f13214405ec43cb1d4e55d32bd7786758e16 (diff) | |
download | dartboat-63d17a12c2a894944ab3760e9b5f3dbf6acb95b5.tar.gz dartboat-63d17a12c2a894944ab3760e9b5f3dbf6acb95b5.tar.xz |
web: store user opts in browser storage
Diffstat (limited to 'web')
-rw-r--r-- | web/dartboat_wasm.c | 1 | ||||
-rw-r--r-- | web/static/dartboat.js | 16 | ||||
-rw-r--r-- | web/static/style.css | 4 |
3 files changed, 18 insertions, 3 deletions
diff --git a/web/dartboat_wasm.c b/web/dartboat_wasm.c index 04d8825..d52f15f 100644 --- a/web/dartboat_wasm.c +++ b/web/dartboat_wasm.c @@ -323,5 +323,6 @@ EMSCRIPTEN_KEEPALIVE void set_delay(int delay) { } int main() { + EM_ASM(read_opts()); start_match(); } diff --git a/web/static/dartboat.js b/web/static/dartboat.js index 87c6020..07c8997 100644 --- a/web/static/dartboat.js +++ b/web/static/dartboat.js @@ -198,7 +198,8 @@ function drawVisit(visit_no, p1_pts, p1_rem, p2_pts, p2_rem, p2_darts) { e.scrollTop = e.scrollHeight; } -function setDelay(val) { +function setDelay(val, update_opts = true) { + if (update_opts) localStorage.setItem('dartboat_delay', val); Module.ccall('set_delay', null, ['number'], [val]); } @@ -206,7 +207,8 @@ function updateDelay(val) { document.getElementById('delay').value = val; } -function setStdev(val) { +function setStdev(val, update_opts = true) { + if (update_opts) localStorage.setItem('dartboat_stdev', val); Module.ccall('set_stdev', null, ['number', 'number'], [val, val]); } @@ -214,6 +216,16 @@ function updateStdev(val) { document.getElementById('stdev').value = val; } +function read_opts() { + let val; + + if ((val = localStorage.getItem('dartboat_delay'))) + setDelay(val, false); + + if ((val = localStorage.getItem('dartboat_stdev'))) + setStdev(val, false); +} + function modal(id) { document.getElementById(id).style.display = 'block'; } diff --git a/web/static/style.css b/web/static/style.css index 70a0c70..e418ef7 100644 --- a/web/static/style.css +++ b/web/static/style.css @@ -44,6 +44,8 @@ div#oi { height: 1.2em; width: 3ch; + outline: #1a1a1a solid 4px; + position: absolute; left: 50%; right: 50%; @@ -312,7 +314,7 @@ div#visits .visit-col6 { color: #888; justify-content: left; font-family: monosp margin: 5vw auto; padding: 2em; outline: #7eab1e solid 2px; - overflow: scroll; + overflow: auto; } @media (max-width: 400px) { |