Results 1 to 2 of 2

Thread: Java dj on-air script

  1. #1
    Join Date
    Aug 2017
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java dj on-air script

    hi i have this on-air script
    but it does not change on the dj's timings?

    here's the script

    HTML Code:
    <p class="one"><link rel="stylesheet" href="css/screen.css" media="screen">
    			<noscript>
    <p>JavaScipt needs to be enabled for this page to function correctly</p>
    </noscript>
    
    <img id="dj" src="djimages/off-air.jpg" alt="Off-line" name="refresh" width="256" height="144">
    
    <script src="scripts/showdj.js"></script></div></p>

    and here's js

    HTML Code:
    (function( d ) {
       'use strict';
    function onair(){
      
       var dj = d.querySelector('#dj'),
           nd = new Date(),
           dy = nd.getDay(),
           hr = nd.getHours(),
           mn = nd.getMinutes();
    
    if(( dy === 7 && hr === 18 && mn >=20 )||
       ( dy === 4 && hr === 18 && mn <=20 )||
       ( dy === 7 && hr === 18 && mn >=20 )||
       ( dy === 4 && hr === 18 && mn <=20 )) {
         dj.src='djimages/strawbs.png';
     }
    else {
    if(( dy === 5 && hr === 13 && mn <=59 )||
       ( dy === 5 && hr === 14 && mn <=59 )) {
         dj.src='djimages/deano.png'; 
     }
    else {
    if(( dy === 6 && hr === 8 && mn <=59 )||
       ( dy === 6 && hr === 9 && mn <=59 )) {
         dj.src='djimages/kayley.png';
     }
    else {
         dj.src='djimages/off-air.jpg';
        }
       }
      }
     }
    
    setInterval( function(){ onair();}, 1000 );
    }( document ));

    it don't seem to work everytime my dj's go on air????? have i done something wrong

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    2,354
    Thanks
    4
    Thanked 289 Times in 282 Posts

    Default

    Hi there strawbs,

    I wrote the original version of that code for you on June 17, 2022 ...

    codingforum.net = On-air script

    ...and have checked your revised code.
    The only problem that i could find was with your own on-air code.

    If you wish to be on air on Sundays and Thursdays between the
    hours of 6:20pm and 7:20pm then this...

    Code:
    if(( dy === 7 && hr === 18 && mn >=20 )||
       ( dy === 4 && hr === 18 && mn <=20 )||
       ( dy === 7 && hr === 18 && mn >=20 )||
       ( dy === 4 && hr === 18 && mn <=20 )) {
         dj.src='djimages/strawbs.png';
     }
    ...should be...

    Code:
    if(( dy === 7 && hr === 18 && mn >=20 )||
       ( dy === 7 && hr === 19 && mn <=19 )||
       ( dy === 4 && hr === 18 && mn >=20 )||
       ( dy === 4 && hr === 19 && mn <=19 )) {
         dj.src='djimages/strawbs.png';
     }

    coothead
    ~ the original bald headed old fart ~

Similar Threads

  1. Java script for Keypress and the script to work
    By aravitejareddy in forum JavaScript
    Replies: 4
    Last Post: 09-05-2010, 03:28 PM
  2. java script
    By rtr.souvik in forum Looking for such a script or service
    Replies: 0
    Last Post: 06-03-2009, 12:23 PM
  3. Need a java script
    By bandaru.anand in forum JavaScript
    Replies: 2
    Last Post: 10-02-2008, 01:49 PM
  4. Java script help?
    By mortenm82 in forum JavaScript
    Replies: 3
    Last Post: 03-10-2007, 02:24 AM
  5. Java script help: please
    By edddie in forum JavaScript
    Replies: 8
    Last Post: 08-26-2005, 05:10 PM

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
  •