hi guys, as im still a noob at javascript, so im asking for your help, i didnt make this script, someone else did and i asked for their permission to change it to my needs, the problem is, i have it working for times that are over an hour long, but i need to also make it possible to display in just under an hour aswell, eg instead of 01:00:00 it would display 60:00 then 59:59 eg, so basically im asking, how can i take the hours out of this, without it currupting the entire JS?
Code:
var HAS_EXPIRED = 'Time has Expired!';
var IS_NONE = 'None';
function secondCountdown(s){
if(s){
var timeleft = document.getElementById('timeleft').innerHTML;
if((timeleft == HAS_EXPIRED) || (timeleft == IS_NONE)) return false;
timeleft = timeleft.replace('<font>', '');
timeleft = timeleft.replace('</font>', '');
var time = timeleft.split(":");
var secs = time[2] * 1;
var mins = time[1] * 1;
var hrs = time[0] * 1;
secs += (mins * 60) + (hrs * 3600);
secs -= 1;
if(secs <= 0){
document.getElementById('timeleft').innerHTML = HAS_EXPIRED;
return false;
} else {
hrs = Math.floor(secs/3600);
secs -= (hrs * 3600);
mins = Math.floor(secs/60);
secs -= (mins * 60);
if(hrs < 10) hrs = '0' + hrs;
if(mins < 10) mins = '0' + mins;
if(secs < 10) secs = '0' + secs;
document.getElementById('timeleft').innerHTML = hrs + ':' + mins + ':' + secs;
}
}
setTimeout('secondCountdown(true)',1000);
}
bootloaderAdd('secondCountdown()');
bootloaderOn();
Cheers.
Dan