Skip to content

Commit

Permalink
add toggle-login
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffrey-wu committed Sep 26, 2024
1 parent adc5d1b commit a449780
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
4 changes: 4 additions & 0 deletions client/multiplayer/room.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ <h1 id="funny-toast-text" class="me-auto text-danger"></h1>
<input class="form-check-input" id="toggle-lock" type="checkbox" role="switch" disabled>
<label class="form-check-label" for="toggle-lock">Lock room from new players</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input" id="toggle-login" type="checkbox" role="switch" disabled>
<label class="form-check-label" for="toggle-login">Require players to be logged in</label>
</div>
<div class="mb-2"></div>
<label for="reading-speed">Reading speed: <span id="reading-speed-display">50</span><br></label>
<input class="form-range" id="reading-speed" type="range" min="0" max="100" step="5">
Expand Down
16 changes: 16 additions & 0 deletions client/multiplayer/room.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ socket.onmessage = function (event) {
case 'start': return next(data);
case 'timer-update': return updateTimerDisplay(data.timeRemaining);
case 'toggle-lock': return toggleLock(data);
case 'toggle-login': return toggleLogin(data);
case 'toggle-powermark-only': return togglePowermarkOnly(data);
case 'toggle-rebuzz': return toggleRebuzz(data);
case 'toggle-select-by-set-name': return toggleSelectBySetName(data);
Expand Down Expand Up @@ -150,6 +151,10 @@ function connectionAcknowledged (message) {
window.localStorage.setItem('USER_ID', USER_ID);

document.getElementById('chat').disabled = message.public;
document.getElementById('toggle-lock').checked = message.lock;
document.getElementById('toggle-lock').disabled = message.public;
document.getElementById('toggle-login').checked = message.login;
document.getElementById('toggle-login').disabled = message.public;
document.getElementById('toggle-rebuzz').checked = message.rebuzz;
document.getElementById('toggle-skip').checked = message.skip;
document.getElementById('toggle-timer').checked = message.timer;
Expand Down Expand Up @@ -577,6 +582,11 @@ function toggleLock ({ lock, username }) {
document.getElementById('toggle-lock').checked = lock;
}

function toggleLogin ({ login, username }) {
logEvent(username, `${login ? 'enabled' : 'disabled'} require players to be logged in`);
document.getElementById('toggle-login').checked = login;
}

function togglePowermarkOnly ({ powermarkOnly, username }) {
logEvent(username, `${powermarkOnly ? 'enabled' : 'disabled'} powermark only`);
document.getElementById('toggle-powermark-only').checked = powermarkOnly;
Expand Down Expand Up @@ -625,6 +635,7 @@ function toggleVisibility ({ public: isPublic, username }) {
document.getElementById('toggle-visibility').checked = isPublic;
document.getElementById('chat').disabled = isPublic;
document.getElementById('toggle-lock').disabled = isPublic;
document.getElementById('toggle-login').disabled = isPublic;
document.getElementById('toggle-timer').disabled = isPublic;
document.getElementById('toggle-timer').checked = true;
}
Expand Down Expand Up @@ -830,6 +841,11 @@ document.getElementById('toggle-lock').addEventListener('click', function () {
socket.send(JSON.stringify({ type: 'toggle-lock', lock: this.checked }));
});

document.getElementById('toggle-login').addEventListener('click', function () {
this.blur();
socket.send(JSON.stringify({ type: 'toggle-login', login: this.checked }));
});

document.getElementById('toggle-powermark-only').addEventListener('click', function () {
this.blur();
socket.send(JSON.stringify({ type: 'toggle-powermark-only', powermarkOnly: this.checked }));
Expand Down
Loading

0 comments on commit a449780

Please sign in to comment.