Created
April 7, 2011 06:43
-
-
Save sidravic/907169 to your computer and use it in GitHub Desktop.
Simple Timer class which updates every ten seconds.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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