This timer works successfully, but I'd like to add a 1 second delay before it starts, here's the code:
any help is appreciated...
also, upon clicking 'start' this displays 00:00
how can I not show : until it all displays?
and, how can I modify it so that it displays this: 0:00 instead of 00:00 ?
thanks
JavaScript:
var Clock = {
totalSeconds: 0,
start: function () {
if (!this.interval) {
var self = this;
function pad(val) { return val > 9 ? val : "0" + val; }
this.interval = setInterval(function () {
self.totalSeconds += 1;
document.getElementById("min").innerHTML = pad(Math.floor(self.totalSeconds / 60 % 60));
document.getElementById("sec").innerHTML = pad(parseInt(self.totalSeconds % 60));
}, 1000);
}
},
reset: function () {
Clock.totalSeconds = null;
clearInterval(this.interval);
document.getElementById("min").innerHTML = "00";
document.getElementById("sec").innerHTML = "00";
delete this.interval;
},
stop: function () {
clearInterval(this.interval);
delete this.interval;
}
};
document.getElementById("start").addEventListener("click", function () { Clock.start(); });
document.getElementById("stop").addEventListener("click", function () { Clock.stop(); });
any help is appreciated...
also, upon clicking 'start' this displays 00:00
how can I not show : until it all displays?
and, how can I modify it so that it displays this: 0:00 instead of 00:00 ?
thanks