www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 10-29-2009, 04:14 AM
    TheWeedMan TheWeedMan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 14
    Looking for timed image script

    Hi

    I am about to help run an charity Internet radio station and ive been asked to try and get something in the form of a script working thats way out my league.
    Im looking for a script that will allow a different image to display on a certian time of the day for 2 hours depending what day it is and within a fortnightly period.

    The idea behind this is to display what dj is onair based on the fortnightly or weekly slot they have booked.

    Any help on this or even if someone could direct me to a script would be greatly appreciated.
    Reply With Quote
      #2  
    Old 10-29-2009, 04:55 AM
    Pprakash Pprakash is offline
    Registered User
     
    Join Date: Sep 2009
    Posts: 13
    Images with time

    try the given file "sun.html" in the browser.


    put the value insted of 1000 and path of images as insted of 'sun1.jpg, 'sun2.jpg', 'sun3.jpg', 'sun3.jpg', as you required in the given code file


    1000 means 1 second


    <html>
    <head>
    <script type="text/javascript">
    var q=0, k;
    function change()
    { q = q+1;
    k=setTimeout("change()",1000);
    var i = new Array("p", "sun1.jpg", "sun2.jpg", "sun3.jpg", "sun4.jpg");
    document.getElementById('p').innerHTML = '<img src="'+i[q]+'" />';
    if(q == 4) q = 0;
    }
    </script>
    </head>
    <body id='p' onload="change('p')">
    </body>
    </html>
    Reply With Quote
      #3  
    Old 10-31-2009, 04:05 AM
    TheWeedMan TheWeedMan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 14
    Thanks for the help Pprakash.

    The issue i have now is this will only allow me to display an array of images on a delayed or timed loop rather than have the image load on a specific time and day within a 2 week period like a scheduled image function...is this even possible?
    Reply With Quote
      #4  
    Old 10-31-2009, 07:46 AM
    Pprakash Pprakash is offline
    Registered User
     
    Join Date: Sep 2009
    Posts: 13
    I cannot understand, please give any example
    Reply With Quote
      #5  
    Old 10-31-2009, 03:36 PM
    TheWeedMan TheWeedMan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 14
    ok heres the same idea only in PHP which is causing confilcts with other scripts on my page. So what I need is the same idea only in Javascript or a simplified version of the script below:-

    <?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-2;

    // MONDAY SCHEDULE
    if ($d == 1 && $h >= 0 && $h < 18) $img = 'img/hosts/DJname.png';
    else if ($d == 1 && $h >= 18 && $h < 20) $img = 'img/hosts/DJname.png';
    else if ($d == 1 && $h >= 20 && $h < 22) $img = 'img/hosts/DJname.png';
    else if ($d == 1 && $h >= 22) $img = 'img/hosts/DJname.png';
    else if ($d == 2 && $h < 0) $img = 'img/hosts/DJname.png';

    // TUESDAY SCHEDULE
    if ($d == 2 && $h >= 0 && $h < 18) $img = 'img/hosts/DJname.png';
    else if ($d == 2 && $h >= 18 && $h < 20) $img = 'img/hosts/DJname.png';
    else if ($d == 2 && $h >= 20 && $h < 22) $img = 'img/hosts/DJname.png';
    else if ($d == 2 && $h >= 22) $img = 'img/hosts/FDJname.png';
    else if ($d == 3 && $h < 0) $img = 'img/hosts/DJname.png';

    // WEDNESDAY SCHEDULE
    if ($d == 3 && $h >= 0 && $h < 18) $img = 'img/hosts/Free.png';
    else if ($d == 3 && $h >= 18 && $h < 20) $img = 'img/hosts/aFree.png';
    else if ($d == 3 && $h >= 20 && $h < 22) $img = 'img/hosts/Free.png';
    else if ($d == 3 && $h >= 22) $img = 'img/hosts/Free.png';
    else if ($d == 4 && $h < 0) $img = 'img/hosts/Free.png';

    // THURSDAY SCHEDULE
    if ($d == 4 && $h >= 0 && $h < 18) $img = 'img/hosts/DJname.png';
    else if ($d == 4 && $h >= 18 && $h < 20) $img = 'img/hosts/DJname.png';
    else if ($d == 4 && $h >= 20 && $h < 22) $img = 'img/hosts/DJname.png';
    else if ($d == 4 && $h >= 22) $img = 'img/hosts/FDJname.png';
    else if ($d == 5 && $h < 0) $img = 'img/hosts/FDJname.png';

    // FRIDAY SCHEDULE
    if ($d == 5 && $h >= 0 && $h < 18) $img = 'img/hosts/DJname.png';
    else if ($d == 5 && $h >= 18 && $h < 20) $img = 'img/hosts/DJname.png';
    else if ($d == 5 && $h >= 20 && $h < 22) $img = 'img/hosts/DJname.png';
    else if ($d == 5 && $h >= 22) $img = 'img/hosts/DJname.png';
    else if ($d == 6 && $h < 0) $img = 'img/hosts/DJname.png';

    // SATURDAY SCHEDULE
    else if ($d == 6 && $h >= 0 && $h < 2) $img = 'img/hosts/DJname.png';
    else if ($d == 6 && $h >= 2 && $h < 4) $img = 'img/hosts/DJname.png';
    else if ($d == 6 && $h >= 4 && $h < 16) $img = 'img/hosts/DJname.png';
    else if ($d == 6 && $h >= 16 && $h < 18) $img = 'img/hosts/DJname.png';
    else if ($d == 6 && $h >= 18 && $h < 20) $img = 'img/hosts/DJname.png';
    else if ($d == 6 && $h >= 20 && $h < 22) $img = 'img/hosts/DJname.png';
    else if ($d == 6 && $h >= 22) $img = 'img/hosts/DJname.png';
    else if ($d == 0 && $h < 0) $img = 'img/hosts/Free.png';

    // SUNDAY SCHEDULE
    else if ($d == 0 && $h >= 0 && $h < 16) $img = 'img/hosts/DJname.png';
    else if ($d == 0 && $h >= 16 && $h < 18) $img = 'img/hosts/DJname.png';
    else if ($d == 0 && $h >= 18 && $h < 20) $img = 'img/hosts/DJname.png';
    else if ($d == 0 && $h >= 20 && $h < 22) $img = 'img/hosts/DJname.png';
    else if ($d == 0 && $h >= 22) $img = 'img/hosts/DJname.png';
    else if ($d == 1 && $h < 0) $img = 'img/hosts/Free.png';
    ?>
    Reply With Quote
      #6  
    Old 11-01-2009, 05:49 AM
    Pprakash Pprakash is offline
    Registered User
     
    Join Date: Sep 2009
    Posts: 13
    I do the some modifications in your given code shown below, and observe. If u have any douts ask.


    <?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');
    $s = date('s'); //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-6;
    $d = $d+1;

    // MONDAY SCHEDULE
    if ($d == 1 && $h >= 0 && $h < 18) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 1 && $h >= 18 && $h < 20) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 1 && $h >= 20 && $h < 22) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 1 && $h >= 22) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 2 && $h < 0) {$img = 'img/hosts/DJname.png';echo $img;}

    // TUESDAY SCHEDULE
    if ($d == 2 && $h >= 0 && $h < 18) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 2 && $h >= 18 && $h < 20) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 2 && $h >= 20 && $h < 22) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 2 && $h >= 22) {$img = 'img/hosts/FDJname.png';echo $img;}
    else if ($d == 3 && $h < 0) {$img = 'img/hosts/DJname.png';echo $img;}

    // WEDNESDAY SCHEDULE
    if ($d == 3 && $h >= 0 && $h < 18) {$img = 'img/hosts/Free.png';echo $img;}
    else if ($d == 3 && $h >= 18 && $h < 20) {$img = 'img/hosts/aFree.png';echo $img;}
    else if ($d == 3 && $h >= 20 && $h < 22) {$img = 'img/hosts/Free.png';echo $img;}
    else if ($d == 3 && $h >= 22) {$img = 'img/hosts/Free.png';echo $img;}
    else if ($d == 4 && $h < 0) {$img = 'img/hosts/Free.png';echo $img;}

    // THURSDAY SCHEDULE
    if ($d == 4 && $h >= 0 && $h < 18) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 4 && $h >= 18 && $h < 20) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 4 && $h >= 20 && $h < 22) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 4 && $h >= 22) {$img = 'img/hosts/FDJname.png';echo $img;}
    else if ($d == 5 && $h < 0) {$img = 'img/hosts/FDJname.png';echo $img;}

    // FRIDAY SCHEDULE
    if ($d == 5 && $h >= 0 && $h < 18) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 5 && $h >= 18 && $h < 20) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 5 && $h >= 20 && $h < 22) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 5 && $h >= 22) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 6 && $h < 0) {$img = 'img/hosts/DJname.png';echo $img;}

    // SATURDAY SCHEDULE
    else if ($d == 6 && $h >= 0 && $h < 2) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 6 && $h >= 2 && $h < 4) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 6 && $h >= 4 && $h < 16) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 6 && $h >= 16 && $h < 18) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 6 && $h >= 18 && $h < 20) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 6 && $h >= 20 && $h < 22) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 6 && $h >= 22) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 0 && $h < 0) {$img = 'img/hosts/Free.png';echo $img;}

    // SUNDAY SCHEDULE
    else if ($d == 0 && $h >= 0 && $h < 16) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 0 && $h >= 16 && $h < 18) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 0 && $h >= 18 && $h < 20) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 0 && $h >= 20 && $h < 22) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 0 && $h >= 22) {$img = 'img/hosts/DJname.png';echo $img;}
    else if ($d == 1 && $h < 0) {$img = 'img/hosts/Free.png';echo $img;}
    ?>
    Reply With Quote
      #7  
    Old 11-01-2009, 08:28 AM
    donatello's Avatar
    donatello donatello is offline
    Registered User
     
    Join Date: Jun 2008
    Location: Europe
    Posts: 487
    Answer: Scriptaculous
    Reply With Quote
      #8  
    Old 11-01-2009, 03:01 PM
    Reis's Avatar
    Reis Reis is offline
    Registered User
     
    Join Date: Jul 2009
    Posts: 55
    Simply make a php script that extracts the correct image, and call the page at certain intervals with ajax to always have the newest image up if the user doesnt refresh the page....
    __________________
    www.dreamsoft.no
    Reply With Quote
      #9  
    Old 11-02-2009, 11:14 AM
    TheWeedMan TheWeedMan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 14
    How do I do that?

    Would you have a script handy lol
    Reply With Quote
      #10  
    Old 11-02-2009, 03:10 PM
    criterion9 criterion9 is offline
    Registered User
     
    Join Date: Jan 2009
    Posts: 981
    This seems like a lot of coding overkill when what it looks like you need a database storing the schedule and a quick SQL call from PHP to see what image should be displayed when the page is loaded. Just saying.
    Reply With Quote
      #11  
    Old 11-03-2009, 01:45 PM
    TheWeedMan TheWeedMan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 14
    Sounds like a great idea and a simple one however the only thing I know about mySQL is my host provides me it lol.
    Ive never wrote anything in SQL.
    Reply With Quote
      #12  
    Old 11-04-2009, 07:45 AM
    TheWeedMan TheWeedMan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 14
    Can anyone provide me with a method for doing this i.e a script that I can copy or instructions?

    My pages are .html extensions with various javascripts running on my index page. I need to be able to display an image of the DJ thats playing at a certain time and a certain day.
    Reply With Quote
      #13  
    Old 11-04-2009, 08:04 AM
    kaafmim's Avatar
    kaafmim kaafmim is offline
    Registered User
     
    Join Date: Nov 2009
    Posts: 32
    The solution to your problem is not in javascript. It can be answered using php. Simply create a php script like this:

    // This script displays an specific image on each specified day and time.
    <?php

    echo "<img alt='DJ photo' src='";

    $now=getdate();

    if (now["mday"]==1 && now[hours]==14 && now[minutes]=32]) {
    echo "thisdj.jpg";
    }
    else if (now["mday"]==1 && now[hours]==14 && now[minutes]=52]) {
    echo "thatdj.jpg";
    }
    else if (now["mday"]==1 && now[hours]==15 && now[minutes]=22]) {
    echo "thatotherdj.jpg";
    }

    // Ans so on. mday is the number of the day, huors and minutes are
    // obvious. you may use seconds too. for more information look at
    // http://www.php.net/manual/en/function.getdate.php
    // Don't forget to close the image tag! :

    echo "'>";

    ?>
    Reply With Quote
      #14  
    Old 11-04-2009, 08:14 AM
    criterion9 criterion9 is offline
    Registered User
     
    Join Date: Jan 2009
    Posts: 981
    Alternatively you could make xml files containing the "schedule" and image URLs you plan. Then you would just need to check which schedule to match using the built in data functions in Javascript and an AJAX call to load the xml files. I get the sneaky suspicion that your DJ schedule will not be the same always and you'd need to change your series of if statements every time you needed to change the schedule. Using an XML file to store your schedule would allow you to change the schedule without having to touch the code that chooses what to display. (This would still be much easier/better using PHP and MySQL since the SQL server could return your desired image URL much more efficiently and wouldn't require browsers to have javascript available and enabled).
    Reply With Quote
      #15  
    Old 11-05-2009, 03:37 AM
    TheWeedMan TheWeedMan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 14
    The only problem i have though is that it cannot be in php.
    My files are html and changing it to a php extension will mess other scripts up. My host wont add commands to the htaccess to allow php to display in html.
    So i more or less need a javascript version of any the above scripts.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 12:11 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.