PDA

View Full Version : clock down clock blues


Webshot
03-13-2006, 12:23 PM
I made this to be a count down clock for the crew of my Ship. It's just to let us know when we will return home from the middle east. It uses little gif's to show the time. But for some reason it will not work. Could someone please tell me what I'm doing wrong. The whole crew and I would be very grateful.

Webshot.



<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function getTime() {}
c1 = new Image(); c1.src = "./images/countdown/1c.gif";
c2 = new Image(); c2.src = "./images/countdown/2c.gif";
c3 = new Image(); c3.src = "./images/countdown/3c.gif";
c4 = new Image(); c4.src = "./images/countdown/4c.gif";
c5 = new Image(); c5.src = "./images/countdown/5c.gif";
c6 = new Image(); c6.src = "./images/countdown/6c.gif";
c7 = new Image(); c7.src = "./images/countdown/7c.gif";
c8 = new Image(); c8.src = "./images/countdown/8c.gif";
c9 = new Image(); c9.src = "./images/countdown/9c.gif";
c0 = new Image(); c0.src = "./images/countdown/0c.gif";
Cc = new Image(); Cc.src = "./images/countdown/Cc.gif";
now = new Date();
//ENTER BELOW THE DATE YOU WISH TO COUNTDOWN TO
later = new Date("AUG 04 2006 0:00:01");
days = (later - now) / 1000 / 60 / 60 / 24;
daysRound = Math.floor(days);
hours = (later - now) / 1000 / 60 / 60 - (24 * daysRound);
hoursRound = Math.floor(hours);
minutes = (later - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
minutesRound = Math.floor(minutes);
seconds = (later - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
secondsRound = Math.round(seconds);

if (secondsRound <= 9) {
document.images.g.src = c0.src;
document.images.h.src = eval("c"+secondsRound+".src");
}
else {
document.images.g.src = eval("c"+Math.floor(secondsRound/10)+".src");
document.images.h.src = eval("c"+(secondsRound%10)+".src");
}
if (minutesRound <= 9) {
document.images.d.src = c0.src;
document.images.e.src = eval("c"+minutesRound+".src");
}
else {
document.images.d.src = eval("c"+Math.floor(minutesRound/10)+".src");
document.images.e.src = eval("c"+(minutesRound%10)+".src");
}
if (hoursRound <= 9) {
document.images.y.src = c0.src;
document.images.z.src = eval("c"+hoursRound+".src");
}
else {
document.images.y.src = eval("c"+Math.floor(hoursRound/10)+".src");
document.images.z.src = eval("c"+(hoursRound%10)+".src");
}
if (daysRound <= 9) {
document.images.x.src = c0.src;
document.images.a.src = c0.src;
document.images.b.src = eval("c"+daysRound+".src");
}
if (daysRound <= 99) {
document.images.x.src = c0.src;
document.images.a.src = eval("c"+Math.floor((daysRound/10)%10)+".src");
document.images.b.src = eval("c"+Math.floor(daysRound%10)+".src");
}
if (daysRound <= 999){
document.images.x.src = eval("c"+Math.floor(daysRound/100)+".src");
document.images.a.src = eval("c"+Math.floor((daysRound/10)%10)+".src");
document.images.b.src = eval("c"+Math.floor(daysRound%10)+".src");
}
newtime = window.setTimeout("getTime();", 1000);
}
// End -->
<!-- Begin
var timerID ;
function tzone(tz, os, ds, cl)
{
this.ct = new Date(0) ; // datetime
this.tz = tz ; // code
this.os = os ; // GMT offset
this.ds = ds ; // has daylight savings
this.cl = cl ; // font color
}
function UpdateClocks()
{
// www.timeanddate.com/worldclock
var ct = new Array(
new tzone('PST: ', -8, 0, 'white'),
new tzone('CST: ', -6, 0, 'white'),
new tzone('EST: ', -5, 1, 'white'),
new tzone('AKST: ', -9, 1, 'white'),
new tzone('SFO: ', -8, 1, 'white'),
new tzone('TYO: ', +9, 0, 'white'),
new tzone('SVO: ', +3, 0, 'white'),
new tzone('KTM: ', +5.75, 0, 'white')
) ;
var dt = new Date() ; // [GMT] time according to machine clock
var startDST = new Date(dt.getFullYear(), 3, 1) ;
while (startDST.getDay() != 0)
startDST.setDate(startDST.getDate() + 1) ;
var endDST = new Date(dt.getFullYear(), 9, 31) ;
while (endDST.getDay() != 0)
endDST.setDate(endDST.getDate() - 1) ;
var ds_active ; // DS currently active
if (startDST < dt && dt < endDST)
ds_active = 1 ;
else
ds_active = 0 ;
// Adjust each clock offset if that clock has DS and in DS.
for(n=0 ; n<ct.length ; n++)
if (ct[n].ds == 1 && ds_active == 1) ct[n].os++ ;
// compensate time zones
gmdt = new Date() ;
for (n=0 ; n<ct.length ; n++)
ct[n].ct = new Date(gmdt.getTime() + ct[n].os * 3600 * 1000) ;
document.all.Clock0.innerHTML =
'<font color="' + ct[0].cl + '"><b>' + ct[0].tz + ClockString(ct[0].ct) + '</b></font>' ;
document.all.Clock1.innerHTML =
'<font color="' + ct[1].cl + '"><b>' + ct[1].tz + ClockString(ct[1].ct) + '</b></font>' ;
document.all.Clock2.innerHTML =
'<font color="' + ct[2].cl + '"><b>' + ct[2].tz + ClockString(ct[2].ct) + '</b></font>' ;
document.all.Clock3.innerHTML =
'<font color="' + ct[3].cl + '"><b>' + ct[3].tz + ClockString(ct[3].ct) + '</b></font>' ;
timerID = window.setTimeout("UpdateClocks()", 1001) ;
}
function ClockString(dt)
{
var stemp, ampm ;
var dt_year = dt.getUTCFullYear() ;
var dt_month = dt.getUTCMonth() + 1 ;
var dt_day = dt.getUTCDate() ;
var dt_hour = dt.getUTCHours() ;
var dt_minute = dt.getUTCMinutes() ;
var dt_second = dt.getUTCSeconds() ;
dt_year = dt_year.toString() ;
if (0 <= dt_hour && dt_hour < 12)
{
ampm = 'AM' ;
if (dt_hour == 0) dt_hour = 12 ;
} else {
ampm = 'PM' ;
dt_hour = dt_hour - 12 ;
if (dt_hour == 0) dt_hour = 12 ;
}
if (dt_minute < 10)
dt_minute = '0' + dt_minute ;
if (dt_second < 10)
dt_second = '0' + dt_second ;
stemp = dt_month + '/' + dt_day + '/' + dt_year.substr(2,2) ;
stemp = stemp + ' ' + dt_hour + ":" + dt_minute + ":" + dt_second + ' ' + ampm ;
return stemp ;
}
// End -->
</script>

Geoserv
03-13-2006, 01:11 PM
where did you get the coding?

I get "Code Corrupted. Insert fresh copy." when I put it on my host. I had to take out "<!-- Begin" and "// End -->" i order for anything to happen.

Geoserv.

Whizzkid
03-13-2006, 01:33 PM
To get an very simple Analog countdown I use the following for one of my websites:

<script language="JavaScript">
TargetDate = "[mm]/[dd]/[yyyy] 3:00 PM";
BackColor = "white";
ForeColor = "black";
CountActive = true;
DisplayFormat = "%%D%% Days<br>%%H%% Hours<br>%%M%% Minutes<br>%%S%% Seconds";
FinishMessage = "[message to be dispalyed when finished]"
</script>

This will only work however if the clock on your computer is right I believe.

Hope this helps

Webshot
03-13-2006, 03:50 PM
Yeah I got it from a web site I took over. They said it use to work but now it doesn't. Is there a script out there that counts down and allows you to use gif instead of the text style numbers.

geoserv

So did it work when you took out the begin and end?

Geoserv
03-14-2006, 07:49 AM
no, go to www.timeanddate.com/worldclock and make one. They will give you the code to make it work.

Geoserv.