clearInterval when location.replacing so that timer stops. Prevents infinite loop

This commit is contained in:
Isaac Connor 2022-02-25 14:13:18 -05:00
parent 372e493b9c
commit 813fd36b0a
1 changed files with 3 additions and 0 deletions

View File

@ -965,6 +965,7 @@ var secondsToCycle = 0;
function nextCycleView() { function nextCycleView() {
secondsToCycle --; secondsToCycle --;
if (secondsToCycle<=0) { if (secondsToCycle<=0) {
secondsToCycle = 0;
window.location.replace('?view=watch&mid='+nextMid+'&mode='+mode+'&cycle=true'); window.location.replace('?view=watch&mid='+nextMid+'&mode='+mode+'&cycle=true');
} }
$j('#secondsToCycle').text(secondsToCycle); $j('#secondsToCycle').text(secondsToCycle);
@ -991,6 +992,7 @@ function cycleNext() {
if (!monitorData[monIdx]) { if (!monitorData[monIdx]) {
console.log('No monitorData for ' + monIdx); console.log('No monitorData for ' + monIdx);
} }
clearInterval(intervalId);
window.location.replace('?view=watch&cycle=true&mid='+monitorData[monIdx].id+'&mode='+mode); window.location.replace('?view=watch&cycle=true&mid='+monitorData[monIdx].id+'&mode='+mode);
} }
@ -1002,6 +1004,7 @@ function cyclePrev() {
if (!monitorData[monIdx]) { if (!monitorData[monIdx]) {
console.log('No monitorData for ' + monIdx); console.log('No monitorData for ' + monIdx);
} }
clearInterval(intervalId);
window.location.replace('?view=watch&cycle=true&mid='+monitorData[monIdx].id+'&mode='+mode); window.location.replace('?view=watch&cycle=true&mid='+monitorData[monIdx].id+'&mode='+mode);
} }