Results 1 to 7 of 7

Thread: Ajax tickler

  1. #1
    Join Date
    Mar 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Ajax tickler

    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...ajaxticker.htm
    3) Describe problem:

    Hi there,
    I currently have two web pages that upload alternate txt files when the web page is opened through PHP

    What I want to get to is a page that uploads the one txt file & then 40 seconds later the other in a loop.

    is is the right area to be looking at an ajax tickler ? can it run the code & then re-run the second section?

  2. #2
    Join Date
    Mar 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    or would it be DHTML?
    http://www.dynamicdrive.com/dynamici...eneraltick.htm

    where I change the
    tickercontent[2]='< PHP here>
    to include the php I want to run

  3. #3
    Join Date
    Mar 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ok Ajax ticker
    not Ajax tickler

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Just so I understand correctly, are you talking about having the ticker do the following:

    1) Load say "contents1.txt" when the page first loads
    2) After 40 seconds, load "contents2.txt", replacing the original contents within the same ticker?
    3) Keep the 2nd ticker contents from then on?
    DD Admin

  5. #5
    Join Date
    Mar 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I was hoping to reuse the php code that loads the text file, so what I wanted from the ticker was

    run php code that displays file1.txt wait 40seconds
    run php code that displays file2.txt wait 40 seconds
    then loop back to file 1.txt wait 40secs etc

    the php is

    PHP Code:
    <?php



    //$file = fopen ("/ftp/gsyharr.txt", "r");
    $file fopen ("http://www.thisisguernsey.co.uk/thirdparty/gsyharr.txt""r");


    if (!
    $file) {
        echo 
    "<p>Unable to open remote file.\n";
        exit;
    }

    ?><table cellpadding=0 width=440 cellspacing=5 align=center border=0>
    <?php

    while (!feof ($file)) {
        
    $line fgets ($file1024);
        
    /* this only works if the title and its tags are on one line */
        
    $vessel substr($line2,13);
        
    $destination substr($line15,13);
        
    $duetime substr($line28,5);
        
    $actualtime substr($line36,6);
        
        
    $new_destination preg_replace('/\s+/'''$destination);
        
    $new_dest preg_replace('/\s+/'''$dest);


        if (
    $vessel == "Commodore Go "){$vessel="Commodore Goodwill";}
        if (
    $vessel == "Condor Vites "){$vessel="Condor Vitesse";}
        if (
    $vessel == "Commodore Cl "){$vessel="Commodore Clipper";}
        if (
    $vessel == "Huelin Dispa "){$vessel="Huelin Dispatch";}
        if (
    $vessel == "Condor Expre "){$vessel="Condor Express";}
        
        
        if (
    $destination == "Jersey/St Ma "){$destination="Jersey/St Malo";}

        if (
    $actualtime == "     E"){$actualtime="     ";}
        
        

        
    $new_destination strtoupper($new_destination);
    $tomorrow 0;
        if (
    $vessel == "Guernsey Harb"){
               echo 
    "<tr><td class=cinema align=left><FONT SIZE=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>Vessel</b></font></td><td class=cinema align=left><FONT SIZE=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>From</b></font></td><td class=cinema align=left><FONT SIZE=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>Time</b></font></td><td class=cinema align=left><FONT SIZE=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>Arrived</b></font></td></tr>";
        
    $tomorrow 1;} 
        else if (
    $destination == "rrow's Arriva")
        {
          echo 
    "<tr><td colspan=4  class='sectionmenucell' valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>&nbsp;Sailings scheduled for tomorrow</b></font></td></tr>";
        
    $tomorrow 2;
        }

    if (
    $dest == "" || $new_destination == $new_dest){

    if (
    $tomorrow == 0){
      echo 
    "<tr><td valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif>$vessel&nbsp;</font></td><td valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>$destination&nbsp;</b></font></td><td width=15% valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif>$duetime&nbsp;</font></td><td valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif>$actualtime&nbsp;</font></td></tr>";
      }}
      
      
    }







    fclose($file);
    echo 
    "</table>";
    ?>
    and

    PHP Code:
    <?php
    //$file = fopen ("ftp/gsyhdep.txt", "r");
    $file fopen ("http://www.thisisguernsey.co.uk/thirdparty/gsyhdep.txt""r");

    if (!
    $file) {
        echo 
    "<p>Unable to open remote file.\n";
        exit;
    }
    ?>
    <table cellpadding=0 width=440 cellspacing=5 align=center border=0>


    <?php

    while (!feof ($file)) {
        
    $line fgets ($file1024);
        
    /* this only works if the title and its tags are on one line */
        
    $vessel substr($line2,13);
        
    $destination substr($line15,13);
        
    $duetime substr($line28,5);
        
    $actualtime substr($line36,5);
        
        
    $new_destination preg_replace('/\s+/'''$destination);
        
    $new_dest preg_replace('/\s+/'''$dest);


        if (
    $vessel == "Commodore Go "){$vessel="Commodore Goodwill";}
        if (
    $vessel == "Condor Vites "){$vessel="Condor Vitesse";}
        if (
    $vessel == "Commodore Cl "){$vessel="Commodore Clipper";}
        if (
    $vessel == "Huelin Dispa "){$vessel="Huelin Dispatch";}
        if (
    $vessel == "Condor Expre "){$vessel="Condor Express";}
        
        
        if (
    $destination == "Jersey/St Ma "){$destination="Jersey/St Malo";}

        

        
    $new_destination strtoupper($new_destination);
    $tomorrow 0;
        if (
    $vessel == "Guernsey Harb"){
               echo 
    "<tr><td colspan=4  class='sectionmenucell' valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>&nbsp;Sailings scheduled for today - $timestamp</b></font></td></tr>";
               echo 
    "<tr><td class=cinema align=left><FONT SIZE=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>Vessel</b></font></td><td class=cinema align=left><FONT SIZE=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>To</b></font></td><td class=cinema align=left><FONT SIZE=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>Time</b></font></td><td class=cinema align=left><FONT SIZE=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>Departed</b></font></td></tr>";
        
    $tomorrow 1;} 
        else if (
    $destination == "rrow's Depart")
        {
          echo 
    "<tr><td colspan=4  class='sectionmenucell' valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>&nbsp;Sailings scheduled for tomorrow</b></font></td></tr>";
        
    $tomorrow 2;
        }

    if (
    $dest == "" || $new_destination == $new_dest){

    if (
    $tomorrow == 0){
      echo 
    "<tr><td valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif>$vessel&nbsp;</font></td><td valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif><b>$destination&nbsp;</b></font></td><td width=15% valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif>$duetime&nbsp;</font></td><td valign=top align=left><font size=1 FACE=Verdana, Arial, Helvetica, sans-serif>$actualtime&nbsp;</font></td></tr>";
      }}
      
      
    }







    fclose($file);
    echo 
    "</table>";
    ?>

  6. #6
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Try the below modified .js file. It lets you rotate between two external files to fetch and display based on the desired interval. On your page you may do something like:

    Code:
    <script type="text/javascript">
    
    var xmlfile=["tickercontent.txt", "tickercontent2.txt"] //path to ticker txt file on your server.
    
    //ajax_ticker(xmlfile, divId, divClass, delay, optionalfadeornot)
    new ajax_ticker(xmlfile, "ajaxticker1", "someclass", [3500, 6000], "fade")
    </script>
    This causes the script to rotate between tickercontent1.txt and tickercontent2.txt to show every 6 seconds. Change these values accordingly. Now, if you specify PHP files instead of .txt files, just make sure the output that gets returned by these files conform to the required content structure. In other words, the returned data should be identical to what's contained inside the .txt files themselves.
    DD Admin

  7. #7
    Join Date
    Mar 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Many thanks will try that

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
  •