Is there a way to slow down a setInterval after certain amount of time?
I have a shoutbox and certain other things that auto-refresh after about 10 seconds. I'm wondering if there's a way for it to work like so:
The user loads the page, setInterval works at refreshing the shoutbox every 10 seconds. If the user's been on the page for 5 minutes with NO activity (such as posting a message in the shoutbox) then setInterval slows down to ... say... 1 minute.. and if inactive for say 30 minutes, then it slows down to every 10 minutes, and if inactive for 3 hours, then stop loading altogether.
I use jQuery and the code is like this:
Code:
$('#shoutbox').load('ajax/shoutbox.php', function(){
$('#shoutbox').fadeIn("fast")
});
setInterval(function(){$('#shoutbox').load('ajax/shoutbox.php')}, 10000);
Any suggestions?
|