Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 12th, 2004, 08:48 AM
Registered User
 
Join Date: Feb 2004
Location: , , United Kingdom.
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>
Reply With Quote
  #2 (permalink)  
Old March 16th, 2004, 03:39 PM
Registered User
 
Join Date: Feb 2004
Location: Newmarket, NH, USA.
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.
Reply With Quote
  #3 (permalink)  
Old January 23rd, 2007, 07:50 PM
Registered User
 
Join Date: Jan 2007
Location: , , .
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.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:18 AM.


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