Jump to content

[Useful] Now On Air Script


mattskills
 Share

Recommended Posts

Hi there, below is a script that will display (for this tutorial an image) depending on the day and hour. If no day/hour is specified it will display a default image for example, auto dj or off air.

 

place this in your page header:

<br />
<br />
/* NOT CURRENTLY USED<br />
<br />
var thedate = new Date();<br />
<br />
var dayofweek = thedate.getDay();<br />
<br />
var hourofday = thedate.getHours();<br />
<br />
<br />
<br />
var GMT = new Date().getTimezoneOffset();<br />
<br />
var offsetGMT = -5 * new Date().getTimezoneOffset()/60;<br />
<br />
*/<br />
<br />
<br />
<br />
// Sun=0 1 2 3 4 5 Sat=6<br />
<br />
var DayOfWeek = new Array('Weekend','Monday','Tuesday','Wednesday','Thursday','Friday','Weekend');<br />
<br />
<br />
<br />
var NoShow = '<img src="images/shownow_klubb24.png" width="277" height="130" />';<br />
<br />
var DH = new Array (7);<br />
<br />
for (d=0; d<7; d++) {<br />
<br />
DH[d] = new Array (24);<br />
<br />
for (h=0; h<24; h++) { DH[d][h] = ''; }<br />
<br />
}<br />
<br />
<br />
<br />
DH[5][19] = '<img src="YOURIMAGEURL" width="XX" height="XX" />'; // this will display an image at 7pm - 8pm on friday <br />
DH[5][20] = '<img src="YOURIMAGEURL" width="XX" height="XX" />'; // this will display an image at 8pm - 9pm on friday <br />
<br />
// Add more according to your schedule<br />
<br />
<br />
<br />
<br />
<br />
function OnNow() {<br />
<br />
var thedate = new Date();<br />
<br />
var dayofweek = thedate.getDay();<br />
<br />
var hourofday = thedate.getHours();<br />
<br />
// alert(dayofweek+':'+hourofday+'<br />'+DH[dayofweek][hourofday]);<br />
<br />
var showOn = DH[dayofweek][hourofday];<br />
<br />
if (showOn == '') { showOn = thedate+'\n\nNo Show Scheduled'; }<br />
<br />
alert(showOn);<br />
<br />
}<br />
<br />
<br />
<br />
function NowON() {<br />
<br />
var thedate = new Date();<br />
<br />
var dayofweek = thedate.getDay();<br />
<br />
var hourofday = thedate.getHours();<br />
<br />
var showOn = DH[dayofweek][hourofday];<br />
<br />
if (showOn == '') { showOn ='<img src="YOURURL" width="XX" height="XX" />'; } //this will be displayed if no image is specified<br />
<br />
document.getElementById('NowOn').innerHTML = showOn;<br />
<br />
}<br />
<br />
function MM_swapImgRestore() { //v3.0<br />
<br />
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;<br />
<br />
}<br />
<br />
function MM_preloadImages() { //v3.0<br />
<br />
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();<br />
<br />
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)<br />
<br />
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}<br />
<br />
}<br />
<br />
<br />
<br />
function MM_findObj(n, d) { //v4.01<br />
<br />
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {<br />
<br />
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}<br />
<br />
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];<br />
<br />
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);<br />
<br />
  if(!x && d.getElementById) x=d.getElementById(n); return x;<br />
<br />
}<br />
<br />
<br />
<br />
function MM_swapImage() { //v3.0<br />
<br />
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)<br />
<br />
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}<br />
<br />
}<br />
<br />

 

Alternatively you may want to put the above code into a seperate javascript file and link to it by putting

 

 

 

Replace your

tag with :

 

Finaly place the following code where you want the image to load:

 

  <br />
<br />
document.write(NowON());<br />
<br />




 Now On Air Requires Javascript

           

           

 

 

Hope that helps, (this isn't my code but i have used it on many sites and it works well, if you know your way around css you can go beyond displaying a simple image or line of text)

 

Matt.

Link to comment
Share on other sites

  • Replies 81
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Fully Functioning Scripts i like Ones that get screwed up by browsers I Hate! Edited by djgary72
Taken out broken link

My Blog https://djgarybaldy.blogspot.com

User of RadioDJ FREE radio playout software since 2010.

How to Install RadioDJ: https://djgarybaldy.blogspot.com/2020/08/how-to-install-radiodj-free-radio.html

RadioDJ is my FAVOURITE piece of software it works when I need It

 

 

Link to comment
Share on other sites

Fully Functioning Scripts i like Ones that get screwed up by browsers I Hate!

 

How many hours have we all spent on getting a script right, onlt to find IE doesn't like it!

I regret not having moved over to FFX many yeras earlier!

Thanks for the greawt script by the way Gary!

If I have helped you with a Freebie- please be kind enough to add a link from your own site or blog to mine- thanks! http://arthurburton.net

 

Thank You!

Link to comment
Share on other sites

How many hours have we all spent on getting a script right, onlt to find IE doesn't like it!

I regret not having moved over to FFX many yeras earlier!

Thanks for the greawt script by the way Gary!

 

Yeah its a pain when IE doesnt want to play Ball been having CSS headaches with IE of late im a Firm believer In Firefox every script i do seems to run well with that.

 

No Worries its been something i had been looking for for years!:clap:

My Blog https://djgarybaldy.blogspot.com

User of RadioDJ FREE radio playout software since 2010.

How to Install RadioDJ: https://djgarybaldy.blogspot.com/2020/08/how-to-install-radiodj-free-radio.html

RadioDJ is my FAVOURITE piece of software it works when I need It

 

 

Link to comment
Share on other sites

While i think the PHP one is Better and doesnt throw any messages at me I reckon Both of these Scripts Deserve a Sticky topic. Theyre both as useful as each other and we dont want em gettin lost in Forums .... Surely

 

Please James I think it be of benefit to all users!

My Blog https://djgarybaldy.blogspot.com

User of RadioDJ FREE radio playout software since 2010.

How to Install RadioDJ: https://djgarybaldy.blogspot.com/2020/08/how-to-install-radiodj-free-radio.html

RadioDJ is my FAVOURITE piece of software it works when I need It

 

 

Link to comment
Share on other sites

  • 1 year later...
ive been using a "whos on air" script for years and it works flawlessy in several browsers what i did was uploaded it to my joomla site called whosonair.php and made a "wrapper" module and in the url pathed it to where the whosonair.php file was and it works heres the script with names i was too lazy to take out......lol ...hope it helps
Link to comment
Share on other sites

<?php

$h = date('G'); //set variable $h to the hour of the day

$d = date('w'); //set variable $d to the day of the week.

$year = date('Y'); //set variable $year to the current year

//G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.

// Adjust 2 hour offset for MST below.

$h = $h-0;

 

 

// MONDAY SCHEDULE

if ($d == 1 && $h >= 0 && $h

else if ($d == 1 && $h >= 4 && $h

else if ($d == 1 && $h >= 14 && $h

else if ($d == 1 && $h >= 16 && $h

else if ($d == 1 && $h >= 18 && $h

else if ($d == 1 && $h >= 20 && $h

else if ($d == 1 && $h >= 22 && $h

else if ($d == 2 && $h

 

 

// TUESDAY SCHEDULE

if ($d == 2 && $h >= 0 && $h

else if ($d == 2 && $h >= 4 && $h

else if ($d == 2 && $h >= 14 && $h

else if ($d == 2 && $h >= 16 && $h

else if ($d == 2 && $h >= 19 && $h

else if ($d == 2 && $h >= 20 && $h

else if ($d == 2 && $h >= 22 && $h

else if ($d == 3 && $h

 

 

// WEDNESDAY SCHEDULE

if ($d == 3 && $h >= 0 && $h

else if ($d == 3 && $h >= 4 && $h

else if ($d == 3 && $h >= 14 && $h

else if ($d == 3 && $h >= 16 && $h

else if ($d == 3 && $h >= 18 && $h

else if ($d == 3 && $h >= 19 && $h

else if ($d == 3 && $h >= 21 && $h

else if ($d == 4 && $h >= 0) $img = '/images/stories/DJs/kittydj.jpg';

 

 

 

 

// THURSDAY SCHEDULE

if ($d == 4 && $h >= 0 && $h

else if ($d == 4 && $h >= 4 && $h

else if ($d == 4 && $h >= 14 && $h

else if ($d == 4 && $h >= 16 && $h

else if ($d == 4 && $h >= 18 && $h

else if ($d == 4 && $h >= 20 && $h

else if ($d == 4 && $h >= 22 && $h

else if ($d == 5 && $h

 

 

 

 

// FRIDAY SCHEDULE

if ($d == 5 && $h >= 0 && $h

else if ($d == 5 && $h >= 4 && $h

else if ($d == 5 && $h >= 14 && $h

else if ($d == 5 && $h >= 16 && $h

else if ($d == 5 && $h >= 18 && $h

else if ($d == 5 && $h >= 20 && $h

else if ($d == 5 && $h >= 22 && $h

else if ($d == 6 && $h >= 0 && $h

 

 

 

 

// SATURDAY SCHEDULE

if ($d == 6 && $h >= 0 && $h

else if ($d == 6 && $h >= 4 && $h

else if ($d == 6 && $h >= 16 && $h

else if ($d == 6 && $h >= 18 && $h

else if ($d == 6 && $h >= 20 && $h

else if ($d == 6 && $h >= 22 && $h

else if ($d == 0 && $h

 

 

 

 

// SUNDAY SCHEDULE

if ($d == 0 && $h >= 0 && $h

else if ($d == 0 && $h >= 2 && $h

else if ($d == 0 && $h >= 10 && $h

else if ($d == 0 && $h >= 14 && $h

else if ($d == 0 && $h >= 16 && $h

else if ($d == 0 && $h >= 18 && $h

else if ($d == 0 && $h >= 20 && $h

else if ($d == 0 && $h >= 22 && $h

else if ($d == 1 && $h

?>

 

 







<?php echo $img; ?>


Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

hi i'm looking for some sort of code in html were the autodj picture changes at certain times of the day?

so for example dj solaris at 12pm till 4pm then from 4pm till 8pm is autodj then from 8pm till 12am is dj foxy and so forth?

check out our website at http://nrgextreme.co.uk and look at the on air now auto dj pic i want that to automatically change

at a certain time of day when our dj's are on

Link to comment
Share on other sites

hi i'm looking for some sort of coding were

our dj's images changes at a certain time of the day?

 

so for example auto dj image changes to djultra's image at say like 12pm till 3pm

then after 3pm djultra's image changes to dj solaris's image then at 5pm dj solaris's

image changes to dj ash's image then after 5pm changes back to the auto dj image

then at 7pm changes to dj foxy image and so on and so forth

 

please help,

 

i have a code but i don't know how to work it see, ill post it here

 

<?php

$h = date('G'); //set variable $h to the hour of the day

$d = date('w'); //set variable $d to the day of the week.

$year = date('Y'); //set variable $year to the current year

//G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.

// Adjust 2 hour offset for MST below.

$h = $h+1;

 

 

// MONDAY SCHEDULE

if ($d == 1 && $h >= 0 && $h

else if ($d == 1 && $h >= 4 && $h

else if ($d == 1 && $h >= 8 && $h

else if ($d == 1 && $h >= 12 && $h

else if ($d == 1 && $h >= 14 && $h

else if ($d == 1 && $h >= 16 && $h

else if ($d == 1 && $h >= 19) $img = 'images/autodj.jpg';

else if ($d == 2 && $h

 

 

// TUESDAY SCHEDULE

if ($d == 2 && $h >= 0 && $h

else if ($d == 2 && $h >= 4 && $h

else if ($d == 2 && $h >= 8 && $h

else if ($d == 2 && $h >= 12 && $h

else if ($d == 2 && $h >= 13 && $h

else if ($d == 2 && $h >= 15 && $h

else if ($d == 2 && $h >= 17 && $h

else if ($d == 2 && $h >= 20) $img = 'images/autodj.jpg';

else if ($d == 3 && $h

 

 

// WEDNESDAY SCHEDULE

if ($d == 3 && $h >= 0 && $h

else if ($d == 3 && $h >= 4 && $h

else if ($d == 3 && $h >= 8 && $h

else if ($d == 3 && $h >= 12 && $h

else if ($d == 3 && $h >= 13 && $h

else if ($d == 3 && $h >= 15 && $h

else if ($d == 3 && $h >= 19) $img = 'images/autodj.jpg';

else if ($d == 4 && $h

 

 

// THURSDAY SCHEDULE

if ($d == 4 && $h >= 0 && $h

else if ($d == 4 && $h >= 4 && $h

else if ($d == 4 && $h >= 8 && $h

else if ($d == 4 && $h >= 12 && $h

else if ($d == 4 && $h >= 13 && $h

else if ($d == 4 && $h >= 15 && $h

else if ($d == 4 && $h >= 19) $img = 'images/autodj.jpg';

else if ($d == 5 && $h

 

 

// FRIDAY SCHEDULE

if ($d == 5 && $h >= 0 && $h

else if ($d == 5 && $h >= 4 && $h

else if ($d == 5 && $h >= 8 && $h

else if ($d == 5 && $h >= 10 && $h

else if ($d == 5 && $h >= 12 && $h

else if ($d == 5 && $h >= 13 && $h

else if ($d == 5 && $h >= 15 && $h

else if ($d == 5 && $h >= 18 && $h

else if ($d == 5 && $h >= 20 && $h

else if ($d == 5 && $h >= 22) $img = 'images/autodj.jpg';

else if ($d == 6 && $h

 

 

// SATURDAY SCHEDULE

else if ($d == 6 && $h >= 0 && $h

else if ($d == 6 && $h >= 4 && $h

else if ($d == 6 && $h >= 5 && $h

else if ($d == 6 && $h >= 8 && $h

else if ($d == 6 && $h >= 9 && $h

else if ($d == 6 && $h >= 10 && $h

else if ($d == 6 && $h >= 11 && $h

else if ($d == 6 && $h >= 12 && $h

else if ($d == 6 && $h >= 13 && $h

else if ($d == 6 && $h >= 14 && $h

else if ($d == 6 && $h >= 15 && $h

else if ($d == 6 && $h >= 17 && $h

else if ($d == 6 && $h >= 19 && $h

else if ($d == 6 && $h >= 22) $img = 'images/autodj.jpg';

else if ($d == 0 && $h

 

 

// SUNDAY SCHEDULE

else if ($d == 0 && $h >= 0 && $h

else if ($d == 0 && $h >= 2 && $h

else if ($d == 0 && $h >= 4 && $h

else if ($d == 0 && $h >= 5 && $h

else if ($d == 0 && $h >= 6 && $h

else if ($d == 0 && $h >= 8 && $h

else if ($d == 0 && $h >= 9 && $h

else if ($d == 0 && $h >= 10 && $h

else if ($d == 0 && $h >= 11 && $h

else if ($d == 0 && $h >= 12 && $h

else if ($d == 0 && $h >= 16 && $h

else if ($d == 0 && $h >= 17 && $h

else if ($d == 0 && $h >= 18 && $h

else if ($d == 0 && $h >= 19 && $h

else if ($d == 0 && $h >= 21) $img = 'images/autodj.jpg';

else if ($d == 1 && $h

?>

 

 

<?php echo $img; ?>

 

 

 

 

i do not know how to work this script, so i put it on our website were the autodj picture is and all the code does is just push everything down? please help

Link to comment
Share on other sites

@djaubs89 did the code that i pasted originally for this script not work for you ?...you can set the background color or image cell spacing and cell padding also the size of the pics (make sure they are similar in size) etc....heres the html script i posted







<?php echo $img; ?>


i did notice tho with this that not all browswers center the pic....firefox does a perfect job....ie and google dont

Link to comment
Share on other sites

i've since changed alot of it....i put in a value for the cellspacing and cellpadding....took out the background image (BG.jpg) and just made it black (#000000) played with the images sizes......but i cant get all browsers to display it in the center...just firefox does the best job of that.....the rest are off center
Link to comment
Share on other sites

  • 2 weeks later...
hi dijultra i'll try......first of all this script is for php.....if your using html there are other scripts for html here......assuming your using php what u want to do is create a folder say for example "dj's" on your server.....mine is in images/stories/dj's....then u want to copy the script i originally posted to your computer and name it...whatever u want.php.....mine is whosonair.php....then u want to edit the script to the path u made the dj's folder and dj's names and times.....the script is written in 24 hour time with 2 hour slots..once u get it all setup......upload it to the main folder to your server.......then u want to create a new "wrapper" module and in the url path it to where u put the whosonair script...mine is http://coco.lastcall-radio.com/whosonair.php...once u have that.. set the size mine is 174x150 no auto height and no auto add.....u also may want to screw with the html code at the bottom of the script for fine tuning for example take out "bg.jpg" and put in a color value....mine is #000000 which is black...make sure your dj's pics are equal size to.....i think mine are either 100x100 or 125x125....once u made that new module..set your paramaters as far as modules go and give it a shot...if i'm forgetting something or you have any problems let me know......its been awhile since ive done this again u can adjust the html code at the bottom to fine tune things eg cell spacing and cell padding i know im forgetting something ...give it a try after you have made all the adjustments and like i said make a new module and path your whosonair.php to that......good luck
Link to comment
Share on other sites

Thanks for the tip Sammy but I do have a folder named dj's with the images in. its images2/dj/images but I have played around but still don't know the timing I want to work weekends from 6pm till 8pm? My time the folder for images are dj's/djdogJpg. But um could you help me out more please maybe teamview me one day and show me were things go script wise, many thanks Edited by djultra89
Link to comment
Share on other sites

ok on the previous page is the script i posted with dj's names in them........heres an example for mondays.....without posting the whole script in here again

// MONDAY SCHEDULE

if ($d == 1 && $h >= 0 && $h

else if ($d == 1 && $h >= 4 && $h

else if ($d == 1 && $h >= 14 && $h

else if ($d == 1 && $h >= 16 && $h

else if ($d == 1 && $h >= 18 && $h

else if ($d == 1 && $h >= 20 && $h

else if ($d == 1 && $h >= 22 && $h

else if ($d == 2 && $h

as u can see dj akky comes on at 22-24 hour ...thats 24 hour time......10:00pm to 12:00 am....2 hour slots...the rest says kittydj which is the name of our auto dj......try to follow the example above......change the path to where your dj's folder is.....make sure the names are correct...for example ...akky4.jpg or kittydj.jpg........try to follow the example above changing the path to your dj's folder and the name of your dj's pic in the appropriate time slots.

Link to comment
Share on other sites

i think 24 hour time works in all time zones but i could be wrong...maybe someone else here can answer that better then me and no thats the only script i use to make that work...the important thing u want to remember is to place that script in the main folder of your server.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×
×
  • Create New...