View Single Post
Old 12-13-2005, 11:43 PM   #3 (permalink)
Jinn
Lover - Protector - Teacher
 
Jinn's Avatar
 
Location: Seattle, WA
You don't need ; on breaks, in Javascript at least.

This code seems to run fine on my box; I just make a blank html and inserted the Script. This sounds like an issue with your CMS or how this jscript is integrated with your other code (if any).

That said, wouldn't it be simpler to write it this way? It seems a bit clunky to make an switch statement for 24 cases when you only have a few options;

Code:
<script language="JavaScript">

var today = new Date();
var hours = today.getHours();

if (hours >= 0 && hours < 6)
	document.write("Midnight");

else if (hours >= 6 && hours <9)
	document.write("Prime");

else if (hours >= 9 && hours <12)
	document.write("Terce");

else if (hours >= 12 && hours < 15)
	document.write("Sext");

else if (hours >= 15 && hours < 18)
	document.write("None");

else if (hours >= 18 && hours < 21)
	document.write("Vespers");

else
	document.write("Compline");

</script>
Just a suggestion.. this will even work if you decide to expand to include the different prayers for each time.. just change the document.write string.
__________________
"I'm typing on a computer of science, which is being sent by science wires to a little science server where you can access it. I'm not typing on a computer of philosophy or religion or whatever other thing you think can be used to understand the universe because they're a poor substitute in the role of understanding the universe which exists independent from ourselves." - Willravel

Last edited by Jinn; 12-14-2005 at 12:00 AM..
Jinn is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76