PDA

View Full Version : Universal Countdown Script



USAMAN
01-30-2008, 09:53 PM
1) Script Title: Universal Countdown Script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex6/universalcountdown.htm

3) Describe problem: How its possible to show

09 Hours
09 Minutes
09 Seconds

instead of only "9 Seconds"

Nile
01-30-2008, 10:37 PM
It says:
2000 hours 53 minutes 37 seconds
You want lines to be in - between those things?

USAMAN
01-30-2008, 10:42 PM
No,
i want to show "09 Seconds" instead of "9 Sekonds" when seconds < 10.

The same by minutes and hours.

Example: "08hours 06minutes 04seconds" instead of "8hours 6minutes 4seconds"

jscheuer1
01-31-2008, 03:08 PM
Replace:


var hourfield=Math.floor((timediff-dayfield*oneDay)/oneHour)
var minutefield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour)/oneMinute)
var secondfield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour-minutefield*oneMinute))

with:


var hourfield=padTime(Math.floor((timediff-dayfield*oneDay)/oneHour));
var minutefield=padTime(Math.floor((timediff-dayfield*oneDay-hourfield*oneHour)/oneMinute));
var secondfield=padTime(Math.floor((timediff-dayfield*oneDay-hourfield*oneHour-minutefield*oneMinute)));

And add this function here:


. . .
this.container.innerHTML=debugstring+this.formatresults(dayfield, hourfield, minutefield, secondfield)
setTimeout(function(){thisobj.showresults()}, 1000) //update results every second
}

function padTime(t){
if(t.toString(10).length<2)
return '0'+t;
return t;
}

/////CUSTOM FORMAT OUTPUT FUNCTIONS BELOW//////////////////////////////

//Create your own custom format function to pass into cdLocalTime.displaycountdown()
//Use arguments[0] to acc . . .

USAMAN
02-03-2008, 07:33 PM
Thank you! It works!