From 3a3f1d129896fad749cf802b41e72d8fc05f0cb8 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Tue, 26 Apr 2022 17:23:52 -0700 Subject: web: support quick rematch, fix checkout points --- web/static/dartboat.js | 49 ++++++++++++++++++++++++++++++------------------- web/static/index.html | 6 +++--- web/static/style.css | 4 +--- 3 files changed, 34 insertions(+), 25 deletions(-) (limited to 'web/static') diff --git a/web/static/dartboat.js b/web/static/dartboat.js index f0855c2..da59e59 100644 --- a/web/static/dartboat.js +++ b/web/static/dartboat.js @@ -38,24 +38,28 @@ function promptClear() { document.getElementById('prompt-input').textContent = ''; } -function isUndoActive() { - return document.getElementById('key_undo').classList.contains('active'); +function setPromptActive() { + document.getElementById('prompt').classList.add('active') } -function toggleUndo() { - document.getElementById('key_undo').classList.toggle('active'); +function setPromptInactive() { + document.getElementById('prompt').classList.remove('active') } -function deactivateUndo() { - document.getElementById('key_undo').classList.remove('active'); +function setPromptInput(ptr) { + document.getElementById('prompt-input').textContent = UTF8ToString(ptr); } -function setPromptActive() { - document.getElementById('prompt').classList.add('active') +function promptMsgL(p) { + document.getElementById('prompt-msg-l').textContent = UTF8ToString(p); } -function setPromptInactive() { - document.getElementById('prompt').classList.remove('active') +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 setKeypad(keypad) { @@ -65,20 +69,27 @@ function setKeypad(keypad) { }); } -function promptHandle(action, data) { - Module.ccall('prompt_handle', null, ['string', 'string'], [action, data]); +function isKeyActive(k) { + return document.getElementById(`key-${UTF8ToString(k)}`).classList + .contains('active'); } -function setPromptInput(ptr) { - document.getElementById('prompt-input').textContent = UTF8ToString(ptr); +function toggleKey(k) { + document.getElementById(`key-${UTF8ToString(k)}`).classList + .toggle('active'); } -function promptMsgL(p) { - document.getElementById('prompt-msg-l').textContent = UTF8ToString(p); +function deactivateKey(k) { + document.getElementById(`key-${UTF8ToString(k)}`).classList + .remove('active'); } -function promptMsgR(p) { - document.getElementById('prompt-msg-r').textContent = UTF8ToString(p); +function setKeyLabelSubmit(ptr) { + document.getElementById('key-submit').textContent = UTF8ToString(ptr); +} + +function setKeyLabelRem(ptr) { + document.getElementById('key-rem').textContent = UTF8ToString(ptr); } function setPlayerActive(n) { @@ -186,7 +197,7 @@ document.addEventListener('keydown', e => { else if (e.key == 'c') promptHandle('clear'); else if (e.key == 'r') - promptHandle('submit_rem'); + promptHandle('rem'); else if (e.key == 'u') promptHandle('undo'); }); diff --git a/web/static/index.html b/web/static/index.html index f986ee9..7fda38c 100644 --- a/web/static/index.html +++ b/web/static/index.html @@ -43,9 +43,9 @@
9
CLEAR
0
-
OK
-
UNDO
-
REMAINING
+
OK
+
UNDO
+
REMAINING
[1] Play against bot
diff --git a/web/static/style.css b/web/static/style.css index 475f726..e22c4ce 100644 --- a/web/static/style.css +++ b/web/static/style.css @@ -222,10 +222,8 @@ div.key.num { font-weight: 700; } -div.key.ok { +div.key#key-submit { grid-row-end: span 2; - - font-size: 2.5em; } div#settings-bar { -- cgit v1.2.3-70-g09d2