Subject: Want to get my realtime clock to chime
Posted By: The Wizard Post Date: 2/11/2004 7:46:23 PM
I've got this script that makes a real time ticking clock with day, date and seconds etc. Now I've tried to modify it so it ticks and chimes on the hour.

I've managed to get it to tick but not chime on the hour properly. I used this command to get it to tick every second but the "chime.wav"  file cuts off after 1 second when the "tick.wav" file kicks in. I've tried increacing the value of the seconds so the "tick.wav" file doesn't come in until after 10 seconds but this causes the chime.wav file to refresh every second until 10 seconds has passed so it still cuts the file short but plays it 10 times over. I wanted it to play the full file which is about 6 seconds long and then have the "tick.wav" file come in when that had finished.

Appreciate any sugestions
Many Thanks
Marty
_________________________________________________
if (minutes+seconds == 0)
bs = ('<bgsound src = "C:/Windows/Media/chime.wav">')
else {
if (seconds >= 0)
bs = ('<bgsound src = "C:/Windows/Media/tick.wav">')
______________________________________________________

Here is the full script...

<HTML>

<HEAD>

<SCRIPT language="JavaScript">


function MakeArrayday(size) {
this.length = size;
for(var i = 1; i <= size; i++) {
this[i] = "";
}
return this;
}
function MakeArraymonth(size) {
this.length = size;
for(var i = 1; i <= size; i++) {
this[i] = "";
}
return this;
}
function MakeArraytime(size) {
this.length = size;
for(var i = 1; i <= size; i++) {
this[i] = "";
}
return this;
}
function funClock() {
if (!document.layers && !document.all)
return;
var runTime = new Date();
var day = runTime.getDay();
var month = runTime.getMonth();
var date = runTime.getDate();
var hours = runTime.getHours();
var minutes = runTime.getMinutes();
var seconds = runTime.getSeconds();
var milliseconds = runTime.getMilliseconds();
var year = runTime.getYear();
var dn = "am";
var mn = "th";


if (day == 0)
day = "Sunday"
else {
if (day == 1)
day = "Monday"
else {
if (day == 2)
day = "Tuesday"
else {
if (day == 3)
day = "Wednesday"
else {
if (day == 4)
day = "Thursday"
else {
if (day == 5)
day = "Friday"
else {
if (day == 6)
day = "Saturday"
};
};
};
};
};
};

if (month == 0)
month = "January"
else {
if (month == 1)
month = "February"
else {
if (month == 2)
month = "March"
else {
if (month == 3)
month = "April"
else {
if (month == 4)
month = "May"
else {
if (month == 5)
month = "June"
else {
if (month == 6)
month = "July"
else {
if (month == 7)
month = "August"
else {
if (month == 8)
month = "September"
else {
if (month == 9)
month = "October"
else {
if (month == 10)
month = "November"
else {
if (month == 11)
month = "December"
};
};
};
};
};
};
};
};
};
};
};

if (date == 1)
mn = "st"
else {
if (date == 21)
mn = "st"
else {
if (date == 31)
mn = "st"
else {
if (date == 2)
mn = "nd"
else {
if (date == 22)
mn = "nd"
else {
if (date == 3)
mn = "rd"
else {
if (date == 23)
mn = "rd"
};
};
};
};
};
};


if (minutes+seconds == 0)
bs = ('<bgsound src = "C:/Windows/Media/Notify.wav">')
else {
if (seconds >= 0)
bs = ('<bgsound src = "C:/Windows/Media/Start.wav">')
}



if (hours >=12) {
dn = "pm";
hours = hours - 12;
}
if (hours == 0) {
hours = 12;
}
if (month <=9) {
month = "0" + month;
}
if (minutes <=9) {
minutes = "0" + minutes;
}
if (seconds <=9) {
seconds = "0" + seconds;
}
movingtime = " " + day + "<BR> " + month + " " + date + "" + mn + " " + year + "<BR><BR> " + hours + ":" + minutes + ":" + seconds + "" + dn + " " + bs + "<BR><BR> and <BR><BR>" + milliseconds + " milliseconds ";
if (document.layers) {
document.layers.clock.document.write(movingtime);
document.layers.clock.document.close();
}
else if (document.all) {
clock.innerHTML = movingtime;
}
setTimeout("funClock()", 1000)
}
window.onload = funClock;

</SCRIPT>

<BODY>
<P align=center>
<B>

<Font Face="Verdana" size="6" color="Orange">
<span id=clock style="position:relative;"></SPAN>
</B>
</FONT>

</BODY></HTML>

Go to topic 9649

Return to index page 950
Return to index page 949
Return to index page 948
Return to index page 947
Return to index page 946
Return to index page 945
Return to index page 944
Return to index page 943
Return to index page 942
Return to index page 941