Timer toggle: manual ON/OFF control, buttons auto-link when ON, NEVER auto-uncheck

This commit is contained in:
2026-04-08 20:28:17 -05:00
parent 1ad1d96cb2
commit 56ecfaad54

View File

@@ -330,13 +330,11 @@ function modTimerToggle(){
if(modTimerRunning){
clearInterval(modTimerInterval);modTimerRunning=false;
document.getElementById('btn-timer-ss').textContent='START';
// Don't auto-uncheck - user controls toggle
broadcastTimerToPlayers(modTimerRemaining,false);
} else {
if(modTimerRemaining<=0)modTimerLoad();
modTimerRunning=true;
document.getElementById('btn-timer-ss').textContent='PAUSE';
// Don't auto-check - user controls toggle
broadcastTimerToPlayers(modTimerRemaining,true);
modTimerInterval=setInterval(()=>{
modTimerRemaining--;
@@ -353,9 +351,6 @@ function modTimerToggle(){
}
},1000);
}
// Sync toggle with running state
const tog=document.getElementById('timer-tog');
if(tog)tog.checked=modTimerRunning;
}
function toggleTimerFromSwitch(){
@@ -367,9 +362,6 @@ function renderModTimerDisplay(){
const s=modTimerRemaining;
el.textContent=fmtTime(s);
el.className='timer-digits'+(s<=5?' danger':s<=10?' warn':'');
// Sync toggle with running state (user controls ON/OFF)
const tog=document.getElementById('timer-tog');
if(tog)tog.checked=modTimerRunning;
}
function modTimerLoad(){
@@ -378,9 +370,6 @@ function modTimerLoad(){
modTimerRunning=false;
clearInterval(modTimerInterval);
document.getElementById('btn-timer-ss').textContent='START';
// Sync toggle with running state (user controls ON/OFF)
const tog=document.getElementById('timer-tog');
if(tog)tog.checked=modTimerRunning;
renderModTimerDisplay();
}
@@ -388,9 +377,6 @@ function modTimerReset(){
clearInterval(modTimerInterval);
modTimerRunning=false;
modTimerRemaining=Math.max(5,parseInt(document.getElementById('mod-timer-set').value)||30);
// Sync toggle with running state (user controls ON/OFF)
const tog=document.getElementById('timer-tog');
if(tog)tog.checked=modTimerRunning;
renderModTimerDisplay();
broadcastTimerToPlayers(modTimerRemaining,false);
}
@@ -403,30 +389,19 @@ function broadcastTimerToPlayers(sec,running){
}catch{}
}
// Timer toggle: user clicks ONCE at start to enable/disable linking
document.getElementById('timer-tog').addEventListener('change',function(e){
const tog=e.target;
if(tog.checked){
// Enable linking - timer auto-syncs with round buttons
} else {
// Disable linking - timer buttons work independently
}
});
// ══════════════════════════════════════════════════════
// MOD ROUND CONTROL
// ══════════════════════════════════════════════════════
function toggleRound(){
if(room.buzzerState.roundOpen){
ws_send({type:'close_round'});
// If linked, pause timer
// If linked (toggle ON) and timer running, pause it
if(document.getElementById('timer-tog').checked && modTimerRunning){
clearInterval(modTimerInterval);modTimerRunning=false;
document.getElementById('btn-timer-ss').textContent='START';
modTimerToggle();
}
} else {
ws_send({type:'open_round'});
// If linked and timer was stopped, start it
// If linked (toggle ON) and timer stopped, start it
if(document.getElementById('timer-tog').checked && !modTimerRunning && modTimerRemaining===0){
modTimerLoad();
modTimerRunning=true;
@@ -448,7 +423,7 @@ function toggleRound(){
function resumeRound(){
ws_send({type:'resume_round'});
// If linked and timer was stopped, resume it
// If linked (toggle ON) and timer stopped, resume it
if(document.getElementById('timer-tog').checked && !modTimerRunning){
modTimerLoad();
modTimerRunning=true;
@@ -467,6 +442,10 @@ function resumeRound(){
}
}
// ══════════════════════════════════════════════════════
// TIMER
// ══════════════════════════════════════════════════════
function renderRoundButtons(){
const btn=document.getElementById('mod-round-btn');
const resumeBtn=document.getElementById('mod-resume-btn');
@@ -480,10 +459,6 @@ function renderRoundButtons(){
btn.className='btn btn-g btn-full';
resumeBtn.style.display='block';
}
// Sync timer toggle with running state (user controls ON/OFF)
const tog=document.getElementById('timer-tog');
if(tog)tog.checked=modTimerRunning;
}
// ══════════════════════════════════════════════════════
@@ -508,9 +483,6 @@ function renderMod(){
renderModPlayerList();
renderModTeams();
renderRoundButtons();
// Sync timer toggle with running state (user controls ON/OFF, toggle reflects state)
const tog=document.getElementById('timer-tog');
if(tog)tog.checked=modTimerRunning;
}
function renderModBuzz(evt){