PDA

View Full Version : Hourly Content Script - Different Every Day Of The Week?



Harrysf
03-08-2008, 02:28 PM
Recently I used a piece of JavaScript that was posted within this specific topic:

http://www.dynamicdrive.com/forums/showthread.php?t=12401&highlight=hourly+iframe+content

I was just wondering if anyone would be willing to make a small alteration to that code so that i could load this from an external .js file, e.g. "on-air.js"
I like the layout of this code, and how you can easily edit the JavaScript to accommodate the different hours of the day.

The only thing that I need in that code to be changed to accommodate an upcoming internet radio station project that i am a co-creator on.
I need the code to be able to be edited so that different hourly content for each day of the week.
This is what I need, and I thought about it a little, this internet radio station that I am going to be a part of will be running on a rather large schedule of which will definitely be different each day, e.g. Auto-DJ on at certain hours of the days, determined on the listener peaks of the specific times.

I would really appreciate a reply on whether anyone would be willing to alter the code for the project I am a part of.
This is going to be quite a project indeed....

Here is most of the script from the link, (but altered to my needs). I would like this sort of layout, except you could have a list for Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday:


var serverTimeOffset = 0; // Offset between UTC/GMT and the server time (hours)
var newsElementID = "news"; // ID of the "news" element

var showTitles = [
"0000 - 0059 news",
"0100 - 0159 news",
"0200 - 0259 news",
"0300 - 0359 news",
"0400 - 0459 news",
"0500 - 0559 news",
"0600 - 0659 news",
"0700 - 0759 news",
"0800 - 0859 news",
"0900 - 0959 news",
"1000 - 1059 news",
"1100 - 1159 news",
"1200 - 1259 news",
"1300 - 1359 news",
"1400 - 1459 news",
"1500 - 1559 news",
"1600 - 1659 news",
"1700 - 1759 news",
"1800 - 1859 news",
"1900 - 1959 news",
"2000 - 2059 news",
"2100 - 2159 news",
"2200 - 2259 news",
"2300 - 2359 news"

// Add more...
];

function addEvent(el, ev, f) {
if(el.addEventListener)
el.addEventListener(ev, f, false);
else if(el.attachEvent)
el.attachEvent("on" + ev, f);
else
el['on' + ev] = f;
}

addEvent(window, "load", function() {
var newsElement = document.getElementById(newsElementID), d;
window.setInterval(
function() {
(d = new Date()).setTime(d.getTime() + (3600000 * serverTimeOffset));
newsElement.innerHTML = showTitles[d.getUTCHours()] || "Nothing.";
},
1000);
});

Thanks.

Harrysf
03-16-2008, 04:32 PM
Please help, i am prepared to advertise your website on the complete website for no charge whatsoever!