Subject: need realtime clock to chime on hour
Posted By: The Wizard Post Date: 2/12/2004 7:48:41 AM
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 by linking a tick.wav file to every second refresh,but it won't chime on the hour for the full length of the chime.wav file (which is about a 6 second melody). It cuts off after 1 second and the tick kicks in.

I've tried increscing the seconds to say..
if (seconds >=10
but then the chime.wav file keeps refreshing every second and plays  it 10 times up to the piont that the tick.wav starts.

Anyway copy the code and see for yourself. I'd Appreciate any sugestions

Many Thanks
Marty

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/chime.wav">')
else {
if (seconds >= 0)
bs = ('<bgsound src = "C:/Windows/Media/tick.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>
Reply By: sahillbb Reply Date: 3/16/2004 2:39:19 PM
Did you ever get an answer to this problem? I am also trying to get the same issue to work and was hoping there was a resolution here.
Reply By: jdgremsjr Reply Date: 1/23/2007 6:50:35 PM
I realize this post is almost three years old but I have found a solution to your problem.



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



with this:


if (minutes ==0 && seconds == 0)
bs = ('<embed src = "C:/Windows/Media/chime.wav" autostart=true hidden=true loop=1 playcount=1>')
else {
bs = ('<embed src = "C:/Windows/Media/tick.wav" autostart=true hidden=true loop=1 playcount=1>')
}


I've tried it, it works.


Go to topic 55122

Return to index page 55
Return to index page 54
Return to index page 53
Return to index page 52
Return to index page 51
Return to index page 50
Return to index page 49
Return to index page 48
Return to index page 47
Return to index page 46