diff options
Diffstat (limited to 'web/static/dartboat.js')
-rw-r--r-- | web/static/dartboat.js | 49 |
1 files changed, 30 insertions, 19 deletions
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'); }); |