Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
|
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 11th, 2004, 08:46 PM
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Want to get my realtime clock to chime

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>


<span id=clock style="position:relative;"></SPAN>
</B>


</BODY></HTML>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Realtime Display Data on DataGridview brucelim80 .NET Framework 2.0 0 November 16th, 2007 04:54 AM
need realtime clock to chime on hour The Wizard JSP Basics 2 January 23rd, 2007 07:50 PM
realtime communication turdy VB.NET 0 February 28th, 2006 10:08 AM
Evaluating Textbox in Realtime without postback mahulda ASP.NET 1.0 and 1.1 Basics 5 March 10th, 2004 03:52 AM
Updating screen due to realtime events? Klom Dark Classic ASP Professional 7 June 5th, 2003 11:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.