diff options
Diffstat (limited to 'web/static')
-rw-r--r-- | web/static/dartboat.js | 30 | ||||
-rw-r--r-- | web/static/index.html | 26 | ||||
-rw-r--r-- | web/static/style.css | 35 |
3 files changed, 63 insertions, 28 deletions
diff --git a/web/static/dartboat.js b/web/static/dartboat.js index 015c541..c1a197a 100644 --- a/web/static/dartboat.js +++ b/web/static/dartboat.js @@ -1,5 +1,6 @@ let match_active = false; let prompt_disable = false; +let prompt_num_darts = false; let match_state, user_rem, boat_rem; let oi_timeout; let delay_ms = 1000; @@ -80,6 +81,14 @@ function updateBoatStateRem(rem) { Module.ccall('get_suggested', null, ['number', 'number'], [rem, 2]); } +function updateUserAvg(avg) { + document.getElementById('user-avg').textContent = avg.toFixed(2); +} + +function updateBoatAvg(avg) { + document.getElementById('boat-avg').textContent = avg.toFixed(2); +} + function promptUpdateRem() { let elem = document.getElementById('user-rem'); let pts = document.getElementById('prompt').textContent; @@ -100,7 +109,8 @@ function promptAppend(val) { let elem = document.getElementById('prompt'); if (elem.textContent.length < 3) { elem.textContent += val; - promptUpdateRem(); + if (!prompt_num_darts) + promptUpdateRem(); } } @@ -121,6 +131,11 @@ function promptBackspace() { promptUpdateRem(); } +function promptNumDarts() { + promptMsgStr('Darts needed?'); + prompt_num_darts = true; +} + function setBoatActive() { document.getElementById('user-state').className = ''; document.getElementById('boat-state').className = 'active'; @@ -147,6 +162,15 @@ function promptSubmit(remaining) { if (!p_user) return; promptClear(); + if (prompt_num_darts) { + if (!stcall('resp_numdarts', null, ['number'], [p_user])) { + oi(); + return; + } + prompt_num_darts = false; + return; + } + if (remaining) p_user = user_rem - p_user; @@ -165,7 +189,7 @@ function promptSubmit(remaining) { } } -function boatVisitRes(rem, n, p1, p2, p3, ptr1, ptr2, ptr3) { +function boatVisitRes(rem, n, p1, p2, p3, ptr1, ptr2, ptr3, avg) { // cannot convert in timeout func because strings are freed in c func let s1 = UTF8ToString(ptr1); let s2 = UTF8ToString(ptr2); @@ -173,6 +197,7 @@ function boatVisitRes(rem, n, p1, p2, p3, ptr1, ptr2, ptr3) { if (delay_ms == 0) { updateBoatRem(rem); + updateBoatAvg(avg); document.getElementById('match').textContent = ''; stcall('draw_match'); setUserActive(); @@ -189,6 +214,7 @@ function boatVisitRes(rem, n, p1, p2, p3, ptr1, ptr2, ptr3) { setTimeout(function() { updateBoatRem(rem); + updateBoatAvg(avg); document.getElementById('prompt').textContent = ''; document.getElementById('match').textContent = ''; stcall('draw_match'); diff --git a/web/static/index.html b/web/static/index.html index a5863ca..7f3e5fc 100644 --- a/web/static/index.html +++ b/web/static/index.html @@ -10,19 +10,21 @@ </head> <body> <div id="main"> - <div id="rem-bar"> - <div id="oi">oi!</div> - <div id="user-state"> - <div id="user-name">User</div> - <div id="user-rem"></div> - <div id="user-sugg"></div> - </div> - <div id="boat-state"> - <div id="boat-name">Bot</div> - <div id="boat-rem"></div> - <div id="boat-sugg"></div> - </div> + <div id="rem-bar"> + <div id="oi">oi!</div> + <div id="user-state"> + <div id="user-name">User</div> + <div id="user-rem"></div> + <div id="user-sugg"></div> + <div id="user-avg"></div> </div> + <div id="boat-state"> + <div id="boat-name">Bot</div> + <div id="boat-rem"></div> + <div id="boat-sugg"></div> + <div id="boat-avg"></div> + </div> + </div> <div id="keypad"> <div id="prompt-container"> <div id="prompt-msg"></div> diff --git a/web/static/style.css b/web/static/style.css index 5287cfc..e099f86 100644 --- a/web/static/style.css +++ b/web/static/style.css @@ -2,8 +2,8 @@ @import url('https://fonts.googleapis.com/css2?family=Source+Serif+Pro:ital,wght@0,400;0,700;1,400&display=swap'); body { - color: #ddd; - background-color: #000; + color: #eee; + background-color: #111; font-family: 'Lato', sans-serif; user-select: none; @@ -39,7 +39,7 @@ div#keypad { div#oi { visibility: hidden; - background-color: #1a1a1a; + background-color: #6c0d0d; font-size: 2em; height: 1.2em; width: 3ch; @@ -79,7 +79,7 @@ div#user-state, div#boat-state { } div#user-state.active, div#boat-state.active { - background-color: #240; + background-color: #2a390a; } div#user-rem, div#boat-rem { @@ -87,10 +87,6 @@ div#user-rem, div#boat-rem { font-weight: bold; } -div#boat-rem { - justify-content: right; -} - div#user-name, div#boat-name { color: #aaa; } @@ -104,6 +100,16 @@ div#user-sugg:after, div#boat-sugg:after { content: '\200b'; } +div#user-avg, div#boat-avg { + font-size: 0.8em; + align-self: left; + width: 100%; +} + +div#user-avg:before, div#boat-avg:before { + content: 'avg: '; +} + div#prompt-container { grid-column: 1 / span 3; @@ -153,13 +159,13 @@ div.key { @media (hover: hover) and (pointer: fine) { div.key:hover { - background-color: #240; + background-color: #2a390a; } } div.key:active { color: #fff; - background-color: #360; + background-color: #3b500e; } div.key.num { @@ -235,7 +241,7 @@ div#settings-bar div.help-button { div#settings-bar input:focus { color: #fff; background-color: #6e41b8; - outline: #5a0 solid 3px; + outline: #7eab1e solid 2px; } div#settings-bar div.help-button:active { @@ -299,12 +305,13 @@ div#match .visit-col6 { color: #888; justify-content: left; font-family: monospa background-color: #222; font-size: 1.4em; font-family: 'Source Serif Pro', serif; + user-select: text; width: calc(min(40em, 90vw) - 4em); max-height: calc(calc(100vh - 10vw) - 4em); margin: 5vw auto; padding: 2em; - outline: #5a0 solid 3px; + outline: #7eab1e solid 2px; overflow: scroll; } @@ -323,11 +330,11 @@ div#match .visit-col6 { color: #888; justify-content: left; font-family: monospa } a { - color: #5a0; + color: #7eab1e; } a:hover { - color: #7d0; + color: #a8e428; } @media (max-aspect-ratio: 9/20) { |