I began putting in my second javascript. I'll be putting a real-time clock in the 'Opening hours' section on the contacts page, so people can see easily if the Recycling Center is open or not. In addition, I began trying to adding a line actually saying if the Center is Open or Closed. Unfortunately, this is proving more difficult than previously expected. According to my site, the Recycling Center NEVER closes! I'll be leaving the clock in, but If I can't get it working by tomorrow I'll be leaving it out.
Below is the code for the clock without the section to add the 'Open' and 'Closed' text:
d = new Date();
nhour = d.getHours();
nmin = d.getMinutes();
nsec = d.getSeconds();
if(nhour == 0) {ap = " AM";nhour = 12;}
else if(nhour <= 11) {ap = " AM";}
else if(nhour == 12) {ap = " PM";}
else if(nhour >= 13) {ap = " PM";nhour -= 12;}
if(nmin <= 9) {nmin = "0" +nmin;}
if(nsec <= 9) {nsec = "0" +nsec;}
document.getElementById('clockbox').innerHTML=""+nhour+":"+nmin+":"+nsec+ap+"";
setTimeout("GetClock()", 1000);
}
window.onload=GetClock;

No comments:
Post a Comment