diff options
Diffstat (limited to 'web/static')
-rw-r--r-- | web/static/dartboat.js | 48 |
1 files changed, 11 insertions, 37 deletions
diff --git a/web/static/dartboat.js b/web/static/dartboat.js index 0014d3a..a47b845 100644 --- a/web/static/dartboat.js +++ b/web/static/dartboat.js @@ -127,36 +127,25 @@ function clearOi() { } } -function updateUserStateRem(ptr) { - document.getElementById('p1-rem').textContent = UTF8ToString(ptr); +function setPlayerActive(n) { + document.querySelectorAll('[id$=-state]').forEach(e => + e.classList[n && e.id == `p${n}-state` ? 'add' : 'remove']('active')); } -function updateBoatStateRem(ptr) { - document.getElementById('p2-rem').textContent = UTF8ToString(ptr); +function updatePlayerRem(n, ptr) { + document.getElementById(`p${n}-rem`).textContent = UTF8ToString(ptr); } -function updateUserName(p) { - document.getElementById('p1-name').textContent = UTF8ToString(p); +function updatePlayerName(n, ptr) { + document.getElementById(`p${n}-name`).textContent = UTF8ToString(ptr); } -function updateBoatName(p) { - document.getElementById('p2-name').textContent = UTF8ToString(p); +function updatePlayerSugg(n, ptr) { + document.getElementById(`p${n}-sugg`).textContent = UTF8ToString(ptr); } -function userSugg(p) { - document.getElementById('p1-sugg').textContent = UTF8ToString(p); -} - -function boatSugg(p) { - document.getElementById('p2-sugg').textContent = UTF8ToString(p); -} - -function updateUserAvg(avg) { - document.getElementById('p1-avg').textContent = avg.toFixed(2); -} - -function updateBoatAvg(avg) { - document.getElementById('p2-avg').textContent = avg.toFixed(2); +function updatePlayerAvg(n, avg) { + document.getElementById(`p${n}-avg`).textContent = avg.toFixed(2); } function setPromptText(ptr) { @@ -175,21 +164,6 @@ function promptUpdateRem() { Module.ccall('update_user_rem_from_pts', null, ['number'], [_promptGet()]); } -function setUserActive() { - document.getElementById('p2-state').classList.remove('active'); - document.getElementById('p1-state').classList.add('active'); -} - -function setBoatActive() { - document.getElementById('p1-state').classList.remove('active'); - document.getElementById('p2-state').classList.add('active'); -} - -function setNoneActive() { - document.getElementById('p1-state').classList.remove('active'); - document.getElementById('p2-state').classList.remove('active'); -} - function scheduleCCall(f, ms, ...args) { let types = []; let vals = []; |