PDA

View Full Version : Ajax tickler



nayone
03-02-2010, 02:05 PM
2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex2/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?

nayone
03-02-2010, 02:11 PM
or would it be DHTML?
http://www.dynamicdrive.com/dynamicindex2/generaltick.htm

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

nayone
03-02-2010, 02:53 PM
ok Ajax ticker
not Ajax tickler :)

ddadmin
03-03-2010, 02:06 AM
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?

nayone
03-03-2010, 09:02 AM
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



//$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 ($file, 1024);
/* this only works if the title and its tags are on one line */
$vessel = substr($line, 2,13);
$destination = substr($line, 15,13);
$duetime = substr($line, 28,5);
$actualtime = substr($line, 36,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
//$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 ($file, 1024);
/* this only works if the title and its tags are on one line */
$vessel = substr($line, 2,13);
$destination = substr($line, 15,13);
$duetime = substr($line, 28,5);
$actualtime = substr($line, 36,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>";
?>

ddadmin
03-03-2010, 09:59 PM
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:


<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.

nayone
03-04-2010, 08:52 AM
Many thanks will try that