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 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) (limited to 'web/static/dartboat.js') 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'); }); -- cgit v1.2.3-70-g09d2