I have multiple timers on a single page which are being started by ajax updates. Every interval has its own name assigned to the username of players. I want to top all timers when the game ends:
This is how intervals are being created: findNewPlayer()
is being called on some events in the game:
function findNewPlayer(){
$.ajax({
url:"check.php",
success:function(data){newTimer(data)}
})
}
function newTimer(username){
var username=setInterval(function() {startTimer()}, 1000);
}
function startTimer(){
//blah blah
}
Now I want to stop all timers and restart the game with current players. How can I use clearInterval on a series of usernames which are not generated in an array? I know if they were array I could do the following but I want to find a way to get collection of all timers with different names in a window.
for (i = 0; i < interValArray.length; i++) {
clearInterval(interValArray[i]);
}