Skip to content

Commit

Permalink
implement toggle-correct
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffrey-wu committed Nov 28, 2024
1 parent 796c26f commit 6a5b5c9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
9 changes: 8 additions & 1 deletion client/singleplayer/bonuses/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function onmessage (message) {
case 'set-year-range': return setYearRange(data);
case 'start-answer': return startAnswer(data);
case 'timer-update': return updateTimerDisplay(data.timeRemaining);
case 'toggle-correct': return toggleCorrect(data);
case 'toggle-select-by-set-name': return toggleSelectBySetName(data);
case 'toggle-show-history': return toggleShowHistory(data);
case 'toggle-standard-only': return toggleStandardOnly(data);
Expand Down Expand Up @@ -145,7 +146,9 @@ function revealNextPart ({ currentPartNumber, part, value }) {
input.className = 'checkbox form-check-input rounded-0 me-1';
input.type = 'checkbox';
input.style = 'width: 20px; height: 20px; cursor: pointer';
input.addEventListener('click', function () { this.blur(); });
input.addEventListener('click', function () {
socket.sendToServer({ type: 'toggle-correct', partNumber: currentPartNumber, correct: this.checked });
});

const inputWrapper = document.createElement('label');
inputWrapper.style = 'cursor: pointer';
Expand Down Expand Up @@ -209,6 +212,10 @@ function startAnswer () {
document.getElementById('reveal').disabled = true;
}

function toggleCorrect ({ partNumber, correct }) {
document.getElementById(`checkbox-${partNumber + 1}`).checked = correct;
}

function toggleSelectBySetName ({ selectBySetName }) {
document.getElementById('difficulty-settings').classList.toggle('d-none', selectBySetName);
document.getElementById('toggle-select-by-set-name').checked = selectBySetName;
Expand Down
Loading

0 comments on commit 6a5b5c9

Please sign in to comment.