Toggle navigation
Home
Latest pastes
FAQ
Random
Register
Login
function countdown
SUBMITTED BY:
Guest
DATE:
Jan. 5, 2014, 2:58 a.m.
FORMAT:
Text only
SIZE:
659 Bytes
Raw
Download
Tweet
HITS:
1130
Go to comments
Report
function Countdown(options) {
var timer,
instance = this,
seconds = options.seconds || 10,
updateStatus = options.onUpdateStatus || function () {},
counterEnd = options.onCounterEnd || function () {};
function decrementCounter() {
updateStatus(seconds);
if (seconds === 0) {
counterEnd();
instance.stop();
}
seconds--;
}
this.start = function () {
clearInterval(timer);
timer = 0;
seconds = options.seconds;
timer = setInterval(decrementCounter, 1000);
};
this.stop = function () {
clearInterval(timer);
};
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus