Skip to content

Instantly share code, notes, and snippets.

@sidravic
Created April 7, 2011 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidravic/907169 to your computer and use it in GitHub Desktop.
Save sidravic/907169 to your computer and use it in GitHub Desktop.
Simple Timer class which updates every ten seconds.
<div class="timer-status"> </div>
<script>
$(document).ready(function(){
timer = function(){
var self = this;
var _timer_count = 0;
var timer_id = null;
self.startTimer = function(callback){
alert(arguments.callee.caller.toString());
timer_id = setInterval(callback, 1000);
}
self.updateTimerStatus = function(){
_timer_count++;
$('.timer-status').html(_timer_count);
if(_timer_count == 10)
clearTimeout(timer_id);
}
}
t = new timer();
t.startTimer(t.updateTimerStatus);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment