|
|
|
@@ -56,12 +56,12 @@ function startTimer(config, state) { |
|
|
|
const result = config.func(state); |
|
|
|
state.timers = state.timers.filter(x => x.timeout != timeout); |
|
|
|
refresh(); |
|
|
|
|
|
|
|
|
|
|
|
if (result) |
|
|
|
startTimer(config, state); |
|
|
|
}, config.delay); |
|
|
|
|
|
|
|
state.timers.push({id: config.id, timeout: timeout, room: config.room}); |
|
|
|
state.timers.push({id: config.id, timeout: timeout, room: config.room, classes: config.classes || []}); |
|
|
|
|
|
|
|
return timeout; |
|
|
|
} |
|
|
|
@@ -82,6 +82,14 @@ function stopRoomTimers(room, state) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function stopClassTimers(timerClass, state) { |
|
|
|
const matches = state.timers.filter(timer => timer.classes.includes(timerClass)); |
|
|
|
matches.forEach(timer => clearTimeout(timer.timeout)); |
|
|
|
|
|
|
|
state.timers = state.timers.filter(timer => !timer.classes.includes(timerClass)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function stopAllTimers(state) { |
|
|
|
state.timers.forEach(x => clearTimeout(x.timeout)); |
|
|
|
state.timers = []; |
|
|
|
|