The following javascript is supposed to display 3 different counters. The counters appear different per timezone. They are supposed to update every second.
Why does it not work?
Heres the code:
head part:
Those who answer my question first get a cornflake!!!
Why does it not work?
Heres the code:
head part:
- Code:
<script type="text/javascript" charset="utf-8">
ftwDay=8;ftwHours=22;ftwMin=42;ftwSec=21;ctfHours=1;ctfMins=42;ctfSec=21;
function updateSroClock() {
var tDate = new Date();
var currentTimeString;
thehours = tDate.getUTCHours()+9;
themins = tDate.getUTCMinutes();
thesecs = tDate.getUTCSeconds();
if (thehours > 23) { thehours = thehours - 24; }
if (thehours < 10) { thehours = "0" + thehours; }
if (themins < 10) { themins = "0" + themins; }
if (thesecs < 10) { thesecs = "0" + thesecs; }
if (thehours > 11) currentTimeString = "" + thehours + ":" + themins + ":" + thesecs + " PM";
else currentTimeString = "" + thehours + ":" + themins + ":" + thesecs + " AM";
document.getElementById("sroclock").innerHTML=currentTimeString;
}
function updateCtf() {
var currentTimeString;
var isReg;
ctfSec-=1;
if(ctfSec<0){ctfSec=59;ctfMins-=1;if(ctfMins<0) {ctfMins=59;ctfHours=1-ctfHours;}}
if(!ctfHours&&ctfMins<10) {
themins=ctfMins;
thesecs=ctfSec;
thehours=0;
isReg=1;
} else {
thehours=ctfHours;
themins=ctfMins-10;
thesecs=ctfSec;
if(themins<0) {themins+=60;thehours-=1;}
isReg=0;
}
if (thehours&&themins<10) {themins="0"+themins;if (thesecs<10) thesecs="0"+thesecs;}
else if ((thehours||themins)&&thesecs<10) {thesecs="0"+thesecs;}
if(isReg) {
if(ctfMins) currentTimeString = themins + ":" + thesecs;
else currentTimeString = thesecs + "s";
} else {
currentTimeString = ""
if(thehours) currentTimeString+=thehours + ":" + themins + ":" + thesecs;
else if(parseInt(themins)) currentTimeString+=themins + ":" + thesecs;
else currentTimeString+=thesecs + "s";
}
document.getElementById("ctfclock").innerHTML=currentTimeString;
}
function updateCtf2() {
var tDate = new Date();
var currentTimeString;
themins = (1-(tDate.getUTCHours()%2))*60+(60-tDate.getUTCMinutes())-11;
thesecs = 60-tDate.getUTCSeconds();
if(themins<0){
themins+=10;
if (thesecs < 10) {thesecs = "0" + thesecs;}
currentTimeString = themins + ":" + thesecs;
} else {
if (themins>59 && themins-60<10) { themins = "1:0" + (themins-60);}
else if (themins>59) { themins = "1:" + (themins-60);}
if (thesecs < 10) { thesecs = "0" + thesecs; }
currentTimeString = themins + ":" + thesecs;
}
document.getElementById("ctfclock").innerHTML=currentTimeString;
}
function updateFtw() {
var currentTimeString;
ftwSec-=1;
if(ftwSec<0){ftwSec=59;ftwMin-=1;if(ftwMin<0) {ftwMin=59;ftwHours-=1;if(ftwHours<0) {ftwHours=23;ftwDay-=1;}}}
thedays=ftwDay;
thehours=ftwHours;
themins=ftwMin;
thesecs=ftwSec;
if (thehours<10) {thehours="0"+thehours;}
if (themins<10) {themins="0"+themins;}
if (thesecs<10) {thesecs="0"+thesecs;}
if (thedays<0) {currentTimeString="NOW!";}
else if(thedays>0) {currentTimeString= thedays + " days " + thehours + ":" + themins + ":" + thesecs;}
else {currentTimeString= thehours + ":" + themins + ":" + thesecs;}
document.getElementById("ftwclock").innerHTML=currentTimeString;
}
</script>
- Code:
<body class="twoColLiqRtHdr" onload="updateCtf(); updateSroClock(); updateFtw(); OnLoadScript(); setInterval('updateCtf();updateSroClock();updateFtw()',1000);">
- Code:
<div id="ftwclock"> </div>
<div id="ctfclock"> </div>
<div id="sroclock"> </div>
Those who answer my question first get a cornflake!!!