Hi i have been looking everywhere and cant seem time to find anything matching,
what i need is a scheduled message on a website, basically stating days of the week and time and who is live on air. also people maybe on air at 17.30 so i have no idea on how to code this.
Here is something I concocted, and which includes an image of the appropriate DJ :-
Code:
<span id = "dj" style="font-size:30px; font-weight:700; font-family: Arial,Verdana,
sans-serif; color: '#FF8000';"></span><img src = "One.gif" id = "theImage">
<script type = "text/javascript">
var show = "No show scheduled at present";
var GMToffset = -5; // Your current GMT offset, whether Standard or Daylight
var now = new Date();
var dy = now.getDay(); // day of week 0-6
now.setHours(GMToffset + now.getHours() + now.getTimezoneOffset() / 60);
var hh = now.getHours();
// The GMT offset ensures that every visitor, regardless of their timezone, will see the schedule
// that is appropriate for the site owner's local time.
// Tip - for testing purposes you can put here
//dy = 5;
//hh = 9;
// or whatever to check that the right show appears at that day/time.
if (dy >=1 && dy <=5) { // days in Javascript are 0 Sunday - 6 Saturday
if (hh >=5 && hh <9) {show = "The Tom Joyner Morning Show"; document.getElementById("theImage").src = "Four.gif"}
if (hh >=9 && hh <14) {show = "Carl T"; document.getElementById("theImage").src = "Two.gif"}
}
if (dy >=1 && dy <=5) {
if (hh >=14 && hh <=18) {show ="Tommy C"}
}
if (dy >= 1 && dy <=4) {
if (hh >=18 && hh <23) {show = "Keith Sweat"}
}
if (dy == 5) {
if (hh >=18 && hh <=23) {show = "G.L.Haywood (House Party)"} //goes on to midnight
}
if (dy == 6) { // Saturday Note the two = signs to mean equals
if (hh >= 6 && hh <9) {show = "The Tom Joyner Morning Show: Right Back At Cha!" }
if (hh >= 9 && hh <14) {show = "Carl T"}
if (hh >=14 && hh <20) {show = "George Fisher"}
if (hh >=20 && hh <22) {show = "Chief Chris Omigee & Momanite Nurse"}
if (hh >=22 && hh <24) {show = "House Party"}
} //End of Saturday Shows
if (dy == 0) { //Sunday Shows
if (hh >= 5 && hh <10) {show = "Porshe Evans (Gospel)"}
if (hh >=10 && hh <12) {show = "The Cravins Brothers Zydeco and Info Show with Charles & Donald Cravins"}
if (hh >=12 && hh <17) {show = "George Fisher"}
if (hh >=17 && hh <21) {show = "Dr. Boogie Live"}
} // End of Sunday Shows
var a = "On air now:- " + show + " \u00A0 \u00A0 \u00A0 \u00A0 "; // spaces must be separted by Unicode spaces to prevent collapse
document.getElementById("dj").innerHTML = a;
</script>
To update every minute wrap the whole thing in a function named display(),
then:-
<body onload = "display()">
and at the end of the function:-
setTimeout("display()", 60000); // every 60 seconds
}
</script>
You can use any simple clock script to display the date and time.
At least once per year, some group of scientists will become very excited and announce that whatever they announced last year about global warming is wrong.
that went way over my head.. sorry, also what if a show is on at 17.30?
sorry to be lame i do appreciate it
In that case you will need to extend the script to take account of minutes.
var hh = now.getHours();
var mn = now.getMinutes();
and then convert the minutes to a decimal of an hour (e.g. 15 minutes is .25,
45 minutes is .75 and so on) and add to hh. (e.g. hh = 14 + .5 = 14.5 (hours) = 14.30).
hh = hh + (mn/60);
Then:-
if (hh >=9 && hh <14.5) {show = "Carl T"; document.getElementById("theImage").src = "Two.gif"} // This DJ on from 0900 - 1430
theImage is naturally an image of the relevant DJ. Here it might be CarlT.jpg.
But I have the idea that you are trying to run before you can walk.
Could you possibly write a full script (like your initial script above) that includes all the changes needed to include minutes. I am trying to make these changes to the script on my website and I am getting all kinds of different results that are not adding up to me. My time zone is -7 Mountain Time also.
Is the
var mn = now.getMinutes();
the only thing you have to add to the top under the hour line or do you have to do something to this line:
and then do you have to change anything on one of the standard lines such as this one:
if (hh >=17 && hh <21) {show = "Dr. Boogie Live"}
I'm not real familiar with this type of script so I appreciate any help. I am more used to simple HTML but I absolutely LOVE this script and it's EXACTLY what I have been looking for as well!
Thank you in advance for any and all help!
-David.
Could you possibly write a full script (like your initial script above) that includes all the changes needed to include minutes.
Thank you in advance for any and all help!
-David.
No. What did your last servant die of? The forum is not a free coding service. I explained how to handle minutes in Post #7.
BTW, the time to say "thanks" is afterwards, not beforehand which gives the - doubtless unintended - impression that you take other people's voluntary unpaid assistance and expertise for granted.
When you say "add to hh" followed by hh = hh + (mn/60);
does that code need to be added to var hh = now.getHours();
or now.setHours(GMToffset + now.getHours() + now.getTimezoneOffset() / 60);
?
I tried changing this
now.setHours(GMToffset + now.getHours() + now.getTimezoneOffset() / 60);
to
now.setHours(GMToffset + now.getHours() + now.getTimezoneOffset() mn / 60);
and got a javascript error on load and it didn't seem to take account of the minutes
var hh = now.getHours();
var mn = now.getMinutes();
hh = hh + (mn/60);
so for example 14:15 becomes 14.25 hours.
Of course lol it was that simple. I was trying to make big thing out of it and change other portions of the script. That's really cool! Works perfect! Thank you so much for setting that straight for me!
A lot of other websites have "time of day" scripts but they all just display a message like, Good Morning, Good Afternoon, Good Evening, and Good Night. Plus they don't include the time offset and minutes so they really suck. This script is a lot more elaborate and like Leemills up there, you are helping me understand this stuff too! Thanks again!
I have been using this script for a short while now and it was working ok until the time got to midnight, I then learned that you must use 0 instead of 24 to represent the 12am hour. After I got past that short dilemma, now the script works fine until 11pm and will not display the proper information for the 11pm hour. I thought changing the midnight number from 24 to 0 might have messed with it so I changed it back a forth a few times and still no fix. Is there anything I can do to fix this? I wonder if it has anything to do with an error in internet time or something?