Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 6 123 ... LastLast
Results 1 to 15 of 78

Thread: on-air script

  1. #1
    New Coder
    Join Date
    Mar 2013
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile on-air script

    hi there i would love my images
    to change on the hour everytime our DJ'S
    come on air, but also would like the page to refresh as well so that
    it shows a new image? i know its in php but its the only way it could show on my site
    but would like a different code to this one? heres the code

    i know it's in php and someone told me that this code would not work!!
    but is there some sort of any other on-air scripts



    <?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 < 4) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 1 && $h >= 4 && $h < 8) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 1 && $h >= 8 && $h < 12) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 1 && $h >= 12 && $h < 14) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 1 && $h >= 14 && $h < 16) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 1 && $h >= 16 && $h < 19) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 1 && $h >= 19) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 2 && $h < 0) $img = 'images2/dj/images/autodj.jpg';

    // TUESDAY SCHEDULE
    if ($d == 2 && $h >= 0 && $h < 4) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 2 && $h >= 4 && $h < 8) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 2 && $h >= 8 && $h < 12) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 2 && $h >= 12 && $h < 13) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 2 && $h >= 13 && $h < 15) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 2 && $h >= 15 && $h < 17) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 2 && $h >= 17 && $h < 20) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 2 && $h >= 20) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 3 && $h < 0) $img = 'images2/dj/images/autodj.jpg';

    // WEDNESDAY SCHEDULE
    else if ($d == 3 && $h >= 4 && $h < 8) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 3 && $h >= 22 && $h < 00) $img = 'images2/dj/images/djultra.jpg';
    else if ($d == 3 && $h >= 8 && $h < 12) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 3 && $h >= 12 && $h < 13) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 3 && $h >= 13 && $h < 15) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 3 && $h >= 15 && $h < 19) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 3 && $h >= 19) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 4 && $h < 0) $img = 'images2/dj/images/autodj.jpg';

    // THURSDAY SCHEDULE
    if ($d == 4 && $h >= 0 && $h < 4) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 4 && $h >= 4 && $h < 8) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 4 && $h >= 8 && $h < 12) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 1 && $h >= 16 && $h < 19) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 4 && $h >= 13 && $h < 15) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 4 && $h >= 15 && $h < 19) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 4 && $h >= 19) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 5 && $h < 0) $img = 'images2/dj/images/autodj.jpg';

    // FRIDAY SCHEDULE
    if ($d == 5 && $h >= 0 && $h < 4) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 5 && $h >= 4 && $h < 8) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 5 && $h >= 8 && $h < 10) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 5 && $h >= 10 && $h < 12) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 5 && $h >= 12 && $h < 13) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 5 && $h >= 13 && $h < 15) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 5 && $h >= 15 && $h < 18) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 5 && $h >= 18 && $h < 20) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 5 && $h >= 20 && $h < 22) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 5 && $h >= 22) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 6 && $h < 0) $img = 'images2/dj/images/autodj.jpg';

    // SATURDAY SCHEDULE
    else if ($d == 6 && $h >= 3 && $h < 22) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 6 && $h >= 22 && $h < 00) $img = 'images2/dj/images/djultra.jpg';
    else if ($d == 6 && $h >= 5 && $h < 8) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 6 && $h >= 8 && $h < 9) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 6 && $h >= 9 && $h < 10) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 6 && $h >= 10 && $h < 11) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 6 && $h >= 11 && $h < 12) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 6 && $h >= 12 && $h < 13) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 6 && $h >= 13 && $h < 14) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 6 && $h >= 14 && $h < 15) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 6 && $h >= 15 && $h < 17) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 1 && $h >= 16 && $h < 19) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 6 && $h >= 19 && $h < 22) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 6 && $h >= 22) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 0 && $h < 0) $img = 'images2/dj/images/autodj.jpg';

    // SUNDAY SCHEDULE
    else if ($d == 0 && $h >= 0 && $h < 2) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 0 && $h >= 2 && $h < 4) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 0 && $h >= 4 && $h < 5) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 0 && $h >= 5 && $h < 6) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 0 && $h >= 6 && $h < 8) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 0 && $h >= 8 && $h < 9) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 0 && $h >= 9 && $h < 10) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 0 && $h >= 10 && $h < 11) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 0 && $h >= 11 && $h < 12) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 0 && $h >= 12 && $h < 16) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 0 && $h >= 16 && $h < 17) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 0 && $h >= 17 && $h < 18) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 0 && $h >= 18 && $h < 19) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 0 && $h >= 19 && $h < 21) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 0 && $h >= 21) $img = 'images2/dj/images/autodj.jpg';
    else if ($d == 1 && $h < 0) $img = 'images2/dj/images/autodj.jpg';
    ?>

    <html>
    <head></head>
    <body>
    <p align="center"><img src="<?php echo $img; ?>"> </p>
    </body>
    </html>
    <p>&nbsp;</p>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,111
    Thanks
    75
    Thanked 4,335 Times in 4,301 Posts
    And again I will ask you: *ALL* of those images are *IDENTICAL*. So your code won't do anything even if it works. Each and every one of them is 'images2/dj/images/autodj.jpg'

    When you actually give us several images to work with, I'll tackle this.

    And no, you don't have to give us the PHP code again. Just give us a list of images and when they should be displayed. A one-day sample would be enough.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New Coder
    Join Date
    Mar 2013
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    djultra will be mondays 3pm till 6pm
    dj Rabbit will be mondays 12pm till 4pm
    dj john will be tuesdays 2pm till 7pm

    then on weekends there will be a show together with djultra and dj rabbit
    between 4pm and 6pm


    here are you're images






    Last edited by djultra; 03-06-2013 at 04:34 PM.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,111
    Thanks
    75
    Thanked 4,335 Times in 4,301 Posts
    Quote Originally Posted by djultra View Post
    djultra will be mondays 3pm till 6pm
    dj Rabbit will be mondays 12pm till 4pm
    dj john will be tuesdays 2pm till 7pm

    then on weekends there will be a show together with djultra and dj rabbit
    between 4pm and 6pm
    ??? And those will be the only times anybody will be on the air? Or do you mean that at other times it will be "autodj"??
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,111
    Thanks
    75
    Thanked 4,335 Times in 4,301 Posts
    Oh...and why did you need the time-zone offset? Because your server is in a different time-zone? Tell me what time-zone the server is in and we'll make it work no matter what time-zone the user is in.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    New Coder
    Join Date
    Mar 2013
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that will be the time autodj is on

  • #7
    New Coder
    Join Date
    Mar 2013
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    time zone is GMT

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,111
    Thanks
    75
    Thanked 4,335 Times in 4,301 Posts
    Quote Originally Posted by djultra View Post
    time zone is GMT
    Well, that makes it easy.

    But then why the adjustment in the PHP code?
    // Adjust 2 hour offset for MST below.
    $h = $h+1;
    And why does it say 2 hour offset but then adjust by only 1 hour? And what is "MST"? In the USA that would be "Mountain Standard Time", but that's sure not only 1 or 2 hours off of GMT.

    Not trying to be picky; just want to be I understand the full problem.

    Let me make 100% sure I understand this:
    djultra will be mondays 3pm till 6pm, GMT
    dj Rabbit will be mondays 12pm till 4pm, GMT
    dj john will be tuesdays 2pm till 7pm, GMT

    then on weekends there will be a show together with djultra and dj rabbit
    between 4pm and 6pm, GMT

    At all other times the display will show autodj.
    What I intend to do is have your PHP code send the current time ON THE SERVER out to the browser, so that we don't have to rely on users having their individual computer clocks set correctly. Then I calculate an "error offset" (that is, how much their computer clock disagrees with the server) and from then on use that offset when determining what time it actually is on the server. That way, we only have to send the time from server to client when the page is first loaded. Make sense?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #9
    New Coder
    Join Date
    Mar 2013
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yup makes perfect sence

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,111
    Thanks
    75
    Thanked 4,335 Times in 4,301 Posts
    Okay...give this a shot.

    If it doesn't seem to work:
    (1) bring up the page in your browser
    (2) click on VIEW menu
    (3) click on SOURCE or PAGE SOURCE menu item
    (4) find the line with var serverTime = ...
    (5) copy/paste what you see here to forum.

    I don't use PHP, so that one line of PHP code is somewhat of a guess. But if you debug as above, we'll figure it out.

    You need to find the two missing image uRLs, of course.

    Code:
    <!DOCTYPE html>
    <html>
    <head></head>
    <body>
    <p align="center"><img id="DJImage" src="images2/dj/images/autodj.jpg" /></p>
    
    ... other page content goes here ...
    
    
    <!-- the script goes *JUST BEFORE* the /body tag -->
    <script type="text/javascript">
    (
      function( ) /* anonymous master function */
      {
          // get the server side date and time into JavaScript:
    <?php
          echo "var serverTime = new Date(" . date("Y,m,j,G,i,s") . ");";
    ?>
    
          // now get current browser date and time:
          var clientTime = new Date();
    
          // get the offset:
          var offset = serverTime.getTime() - clientTime.getTime();
    
          // here is the mapping from short names to image names
          var images = {
              "auto"   : "autodj.jpg",
              "ultra"  : "ultra.gif",
              "both"   : "djpic.jpg",
              "rabbit" : ".... you didn't give me this image ...",
              "john"   : ".... you didn't give me this image ..."
          ];
    
          // then here is the function that sets the images in place:
          function setImage( )
          {
              // current client time
              var now = new Date();
              // adjust that to get current server time:
              now.setTime( now.getTime() + offset );
    
              // and then follow the rules given:
              var wkday = now.getDay();
              var hour  = new.getHour(); // remember: this is adjusted to GMT now
    
              var dj = "auto"; // this is assumed if none of the other conditions apply
    
              // djultra will be mondays 3pm till 6pm, GMT
              if ( wkday === 1 && hour >= 15 && hour < 18 )
              {
                  dj = "ultra";
              } 
    
              // dj Rabbit will be mondays 12pm till 4pm, GMT 
              // *** MISTAKE: that means ultra and rabbit overlap by an hour!
              // *** CHANGED: rabbit does 12pm until 3pm, GMT
              else if ( wkday === 1 && hour >= 12 && hour < 15 )
              {
                  dj = "rabbit";
              } 
              // dj john will be tuesdays 2pm till 7pm, GMT
              else if ( wkday === 2 && hour >= 14 && hour < 19 )
              {
                  dj = "john";
              } 
              // on weekends there will be a show together 
              // with djultra and dj rabbit between 4pm and 6pm, GMT
              else if ( ( wkday === 0 || wkday === 6 ) && hour >= 16 && hour < 18 )
              {
                  dj = "both";
              } 
              // get the image file name based on dj name
              var imageURL = "images2/dj/images/" + images[dj];
              // and change the displayed image:
              document.getElementByID("DJImage").src = imageURL;
    
              // and do this again in, say, 30 seconds:
              setTimeout( setImage, 30000 );
    
          } // end of setImage function
    
          setImage( ); // invoke it once to get started
    
      } // end of anonymous master function
    )(); // self-invoke anonymous function
    </script>
    </body>
    </html>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #11
    New Coder
    Join Date
    Mar 2013
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok ill try that but what do i name my index? index.php or index.html

  • #12
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,111
    Thanks
    75
    Thanked 4,335 Times in 4,301 Posts
    index.php, of course. If it has *ANY* PHP code in it--even that one line--it has to be ".php".
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #13
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,071
    Thanks
    38
    Thanked 498 Times in 492 Posts
    The problem with double posting is you end up following 2 threads...
    See post #36 of: I need help with an On Air script for a radio station website.

  • #14
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,071
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Lightbulb

    Copied from the other thread ...

    You can put your PHP code back into this example, but I saw no particular need for it using JS only.
    I used the setInterval() function to check for changes every hour if the page is open for that length of time.

    Note your logic can be vastly compressed with a bit of forethought...
    The value of $h (hours) can only be within the range of 0..23 in military time.
    Therefore all you need to do is check for $h < hour starting a midnight and staying sequential in your test logic.

    Also, you only need to check for the day once and not each and every time.
    If the schedule stays the same for any one or more days, the logic could be compressed further.

    Substitute your own path and image file names into the appropriate lines
    and ask questions about the following logic if it does not make sense to you...

    Code:
    <html>
    <head>
    <title> DJ times </title>
    </head>
    <body>
    <div id="DJtimes">
     <img id="DJpix" src="" title='No show' alt="No show" style="font-size:3em; background-color:orange">
    </div>
    
    <script type="text/javascript">
    function DJdisplay() {
     var now = new Date();
     var $d = now.getDay();
    
     var $h = now.getHours();  // adjust for MST if necessary or use UTC time
    // var $h = now.getMinutes();  // for testing purposes only before hh:24
    
     var $year = now.getFullYear();
    
     var baseURL = 'http://www.nova.edu/hpd/otm/pics/4fun/';  // change to: './images2/dj/images/
     var $img = document.getElementById('DJpix');
    
    /*
     $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;
    */
    
     if ($d == 1) {  // MONDAY SCHEDULE
           if ($h < 4) $img.src = baseURL+''
      else if ($h < 8) $img.src = baseURL+'11.jpg'
      else if ($h < 12) $img.src = baseURL+'12.jpg'
      else if ($h < 14) $img.src = baseURL+'13.jpg'
      else if ($h < 16) $img.src = baseURL+'13.jpg'
      else if ($h < 19) $img.src = baseURL+'14.jpg'
      else if ($h >= 19) $img.src = baseURL+'15.jpg';
     }
    
     if ($d == 2) {  // TUESDAY SCHEDULE
           if ($h < 4) $img.src = baseURL+''
      else if ($h < 8) $img.src = baseURL+'21.jpg'
      else if ($h < 12) $img.src = baseURL+'22.jpg'
      else if ($h < 13) $img.src = baseURL+'23.jpg'
      else if ($h < 15) $img.src = baseURL+'23.jpg'
      else if ($h < 17) $img.src = baseURL+'24.jpg'
      else if ($h < 20) $img.src = baseURL+'25.jpg'
      else if ($h >= 20) $img.src = baseURL+'21.jpg';
     }
    
     if ($d == 3) {  // WEDNESDAY SCHEDULE
           if ($h < 4) $img.src = baseURL+''
      else if ($h < 8) $img.src = baseURL+'31.jpg'
      else if ($h < 12) $img.src = baseURL+'32.jpg'
      else if ($h < 13) $img.src = baseURL+'33.jpg'
      else if ($h < 15) $img.src = baseURL+'33.jpg'
      else if ($h < 17) $img.src = baseURL+'34.jpg'
      else if ($h < 20) $img.src = baseURL+'35.jpg'
      else if ($h >= 20) $img.src = baseURL+'31.jpg';
     }
    
     if ($d == 4 ) {  // THURSDAY SCHEDULE
           if ($h < 4) $img.src = baseURL+''
      else if ($h < 8) $img.src = baseURL+'41.jpg'
      else if ($h < 12) $img.src = baseURL+'42.jpg'
      else if ($h < 13) $img.src = baseURL+'43.jpg'
      else if ($h < 15) $img.src = baseURL+'43.jpg'
      else if ($h < 17) $img.src = baseURL+'44.jpg'
      else if ($h < 20) $img.src = baseURL+'45.jpg'
      else if ($h >= 20) $img.src = baseURL+'41.jpg';
     }
    
     if ($d == 5) {  // FRIDAY SCHEDULE
           if ($h < 4) $img.src = baseURL+''
      else if ($h < 8) $img.src = baseURL+'51.jpg'
      else if ($h < 12) $img.src = baseURL+'52.jpg'
      else if ($h < 13) $img.src = baseURL+'53.jpg'
      else if ($h < 15) $img.src = baseURL+'53.jpg'
      else if ($h < 17) $img.src = baseURL+'54.jpg'
      else if ($h < 20) $img.src = baseURL+'55.jpg'
      else if ($h >= 20) $img.src = baseURL+'51.jpg';
     }
    
     if ($d == 6) {  // SATURDAY SCHEDULE
           if ($h < 5) $img.src = baseURL+''
      else if ($h < 8) $img.src = baseURL+'11.jpg'
      else if ($h < 9) $img.src = baseURL+'21.jpg'
      else if ($h < 10) $img.src = baseURL+'31.jpg'
      else if ($h < 11) $img.src = baseURL+'41.jpg'
      else if ($h < 12) $img.src = baseURL+'51.jpg'
      else if ($h < 13) $img.src = baseURL+'11.jpg'
      else if ($h < 14) $img.src = baseURL+'21.jpg'
      else if ($h < 15) $img.src = baseURL+'31.jpg'
      else if ($h < 17) $img.src = baseURL+'41.jpg'
      else if ($h < 19) $img.src = baseURL+'51.jpg'
      else if ($h < 22) $img.src = baseURL+'11.jpg'
      else if ($h >= 22) $img.src = baseURL+'21.jpg';
     }
    
     if ($d == 0) { // SUNDAY SCHEDULE
           if ($h < 2) $img.src = baseURL+''
      else if ($h < 4) $img.src = baseURL+'11.jpg'
      else if ($h < 5) $img.src = baseURL+'21.jpg'
      else if ($h < 6) $img.src = baseURL+'31.jpg'
      else if ($h < 8) $img.src = baseURL+'41.jpg'
      else if ($h < 9) $img.src = baseURL+'51.jpg'
      else if ($h < 10) $img.src = baseURL+'11.jpg'
      else if ($h < 11) $img.src = baseURL+'21.jpg'
      else if ($h < 12) $img.src = baseURL+'31.jpg'
      else if ($h < 16) $img.src = baseURL+'41.jpg'
      else if ($h < 17) $img.src = baseURL+'51.jpg'
      else if ($h < 18) $img.src = baseURL+'11.jpg'
      else if ($h < 19) $img.src = baseURL+'21.jpg'
      else if ($h < 21) $img.src = baseURL+'31.jpg'
      else if ($h >= 21) $img.src = baseURL+'41.jpg';
     }
    }
    
    window.onload = function () {
      DJdisplay();
      var interval = 60*60*1000;  // 1 hour checks
    //  var interval = 60*100;      // 1 minute checks for testing purposes only
      var t = setInterval("DJdisplay()",interval);
    }
    </script>
    
    </body>
    </html>
    Change the interval checks to every minute if the hour images need to be changed at the top of the hour.
    Last edited by jmrker; 03-07-2013 at 01:55 AM.

  • #15
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,111
    Thanks
    75
    Thanked 4,335 Times in 4,301 Posts
    Yes, jmrker, but your script depends on (a) the users' computer clocks being set correctly and (b) the users being in the same time zone as the server [though it's easy to adjust for the latter].

    See how I pass the server time in, from PHP, and then use the discovered offset in all other calculations.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  
    Page 1 of 6 123 ... LastLast

    Posting Permissions

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