Page 1 of 9 123 ... LastLast
Results 1 to 10 of 82
  1. #1

    [Useful] Now On Air Script

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

    Replace your <body> tag with :
    Code:
    <body onLoad="NowON();">
    Finaly place the following code where you want the image to load:

    Code:
      <script type="text/javascript">
    
    document.write(NowON());
    
    </script>
    
    <div id='NowOn' onClick="NowON()">
    
      <div align="left">Now On Air Requires Javascript</div>
    
                
    
                </div>

    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.

  2. #2
    garybaldy72uk's Avatar
    Title
    Senior Member
    Join Date
    Oct 2010
    Location
    Manchester
    Posts
    671
    Rep Power
    29
    Fully Functioning Scripts i like Ones that get screwed up by browsers I Hate!
    Last edited by garybaldy72uk; 09-29-2011 at 09:01 AM. Reason: Taken out broken link

  3. #3
    Arfa B!'s Avatar
    Title
    Previously Known As arthurburton
    Rank Amateur
    Join Date
    Jul 2008
    Posts
    784
    Rep Power
    41

    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!

  4. #4
    When i've used this script it has worked in Internet Explorer and Google Chrome , not tried any other browsers, to my knowledge it it fully functional.

  5. #5
    garybaldy72uk's Avatar
    Title
    Senior Member
    Join Date
    Oct 2010
    Location
    Manchester
    Posts
    671
    Rep Power
    29
    Quote Originally Posted by Arfa B! View Post
    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!

  6. #6
    garybaldy72uk's Avatar
    Title
    Senior Member
    Join Date
    Oct 2010
    Location
    Manchester
    Posts
    671
    Rep Power
    29
    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!

  7. #7
    sammy7545's Avatar
    Title
    Junior Member
    Join Date
    Sep 2012
    Location
    new york
    Posts
    28
    Rep Power
    7
    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

  8. #8
    sammy7545's Avatar
    Title
    Junior Member
    Join Date
    Sep 2012
    Location
    new york
    Posts
    28
    Rep Power
    7
    <?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 < 4) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 1 && $h >= 4 && $h < 14) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 1 && $h >= 14 && $h < 16) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 1 && $h >= 16 && $h < 18) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 1 && $h >= 18 && $h < 20) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 1 && $h >= 20 && $h < 22) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 1 && $h >= 22 && $h < 24) $img = '/images/stories/DJs/akky4.jpg';
    else if ($d == 2 && $h < 0) $img = '/images/stories/DJs/kittydj.jpg';


    // TUESDAY SCHEDULE
    if ($d == 2 && $h >= 0 && $h < 4) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 2 && $h >= 4 && $h < 14) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 2 && $h >= 14 && $h < 16) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 2 && $h >= 16 && $h < 19) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 2 && $h >= 19 && $h < 20) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 2 && $h >= 20 && $h < 22) $img = '/images/stories/DJs/johnny.jpg';
    else if ($d == 2 && $h >= 22 && $h < 24) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 3 && $h < 0) $img = '/images/stories/DJs/kittydj.jpg';


    // WEDNESDAY SCHEDULE
    if ($d == 3 && $h >= 0 && $h < 4) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 3 && $h >= 4 && $h < 14) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 3 && $h >= 14 && $h < 16) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 3 && $h >= 16 && $h < 18) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 3 && $h >= 18 && $h < 19) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 3 && $h >= 19 && $h < 21) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 3 && $h >= 21 && $h < 24) $img = '/images/stories/DJs/BRIAN1.jpg';
    else if ($d == 4 && $h >= 0) $img = '/images/stories/DJs/kittydj.jpg';




    // THURSDAY SCHEDULE
    if ($d == 4 && $h >= 0 && $h < 4) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 4 && $h >= 4 && $h < 14) $img = '/images/stories/DJs/kitty-dj.jpg';
    else if ($d == 4 && $h >= 14 && $h < 16) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 4 && $h >= 16 && $h < 18) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 4 && $h >= 18 && $h < 20) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 4 && $h >= 20 && $h < 22) $img = '/images/stories/DJs/johnny.jpg';
    else if ($d == 4 && $h >= 22 && $h < 24) $img = '/images/stories/DJs/akky4.jpg';
    else if ($d == 5 && $h < 0) $img = '/images/stories/DJs/kittydj.jpg';




    // FRIDAY SCHEDULE
    if ($d == 5 && $h >= 0 && $h < 4) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 5 && $h >= 4 && $h < 14) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 5 && $h >= 14 && $h < 16) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 5 && $h >= 16 && $h < 18) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 5 && $h >= 18 && $h < 20) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 5 && $h >= 20 && $h < 22) $img = '/images/stories/DJs/Sammy-.jpg';
    else if ($d == 5 && $h >= 22 && $h < 24) $img = '/images/stories/DJs/mrsjones.jpg';
    else if ($d == 6 && $h >= 0 && $h < 2) $img = '/images/stories/DJs/kittydj.jpg';




    // SATURDAY SCHEDULE
    if ($d == 6 && $h >= 0 && $h < 4) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 6 && $h >= 4 && $h < 16) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 6 && $h >= 16 && $h < 18) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 6 && $h >= 18 && $h < 20) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 6 && $h >= 20 && $h < 22) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 6 && $h >= 22 && $h < 24) $img = '/images/stories/DJs/thecocos.jpg';
    else if ($d == 0 && $h < 0) $img = '/images/stories/DJs/kittydj.jpg';




    // SUNDAY SCHEDULE
    if ($d == 0 && $h >= 0 && $h < 2) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 0 && $h >= 2 && $h < 10) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 0 && $h >= 10 && $h < 14) $img = '/images/stories/DJs/thecocos.jpg';
    else if ($d == 0 && $h >= 14 && $h < 16) $img = '/images/stories/DJs/BRIAN1.jpg';
    else if ($d == 0 && $h >= 16 && $h < 18) $img = '/images/stories/DJs/mrsjones.jpg';
    else if ($d == 0 && $h >= 18 && $h < 20) $img = '/images/stories/DJs/johnny.jpg';
    else if ($d == 0 && $h >= 20 && $h < 22) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 0 && $h >= 22 && $h < 24) $img = '/images/stories/DJs/kittydj.jpg';
    else if ($d == 1 && $h < 0) $img = '/images/stories/DJs/kittydj.jpg';
    ?>


    <html>
    <meta http-equiv="Content-Language" content="en-us">
    <body bgcolor="#000000">
    <div align="left">
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="170" height="134" id="AutoNumber1" align="left">
    <tr>
    <td width="171" height="60" bordercolordark="#FF0000" background="/images/stories/BG.jpg">
    <p align="center">
    <img src="<?php echo $img; ?>"height="100" width="100"><p align="left">
    </td>
    </tr>
    </table>
    </div>
    </body>
    </html>

  9. #9
    sammy7545's Avatar
    Title
    Junior Member
    Join Date
    Sep 2012
    Location
    new york
    Posts
    28
    Rep Power
    7
    sorry for the large post but the script works.....of course you'll have to edit the path to the images.....u can see it on our website at http://coco.lastcall-radio.com/ under "your current dj".....thanks

  10. #10

    Title
    Junior Member
    Join Date
    Sep 2012
    Posts
    10
    Rep Power
    7
    thanks for this matt

Similar Threads

  1. Protools vs Audition
    By Jinglemaster in forum Audio Production
    Replies: 9
    Last Post: 07-28-2010, 12:18 AM
  2. Could use a voice over read for more details
    By brandon_g in forum Request A Free Voiceover
    Replies: 41
    Last Post: 12-04-2009, 02:33 PM
  3. U.S. Webcasting Fee's overturned
    By saint in forum General Internet Radio Discussions
    Replies: 0
    Last Post: 08-22-2009, 03:17 PM
  4. Introducing bodalgo - The new voice over market place
    By bodalgo in forum Audio Production
    Replies: 3
    Last Post: 03-22-2009, 02:11 AM
  5. Hi you all
    By CA101 in forum Introduce Yourself
    Replies: 1
    Last Post: 11-28-2008, 07:42 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •