Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics 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 12th, 2004, 08:48 AM
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default need realtime clock to chime on hour

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>


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


</BODY></HTML>
 
Old March 16th, 2004, 03:39 PM
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
 
Old January 23rd, 2007, 07:50 PM
Registered User
 
Join Date: Jan 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Hour by Hour Matrix Report Ed_Conde BOOK: Professional SQL Server 2005 Reporting Services ISBN: 0-7645-8497-9 0 August 12th, 2008 02:51 PM
Realtime Display Data on DataGridview brucelim80 .NET Framework 2.0 0 November 16th, 2007 04:54 AM
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
Want to get my realtime clock to chime The Wizard Pro JSP 0 February 11th, 2004 08:46 PM





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