D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] OT: Could anyone help with a bit of Javascript please?

 

Rob Beard wrote:
> When the page loads and the script runs, it loads the contents of the 
> text file into the memory and then goes through each item one after the 
> other.  However, what I want is something that will automatically update 
> itself, so if for instance anything gets added to the text file that it 
> picks it up when it cycles through again.
>   
Not sure of the actual coding to be honest.  However, you could say 
something like;

function LoadFile()
{
load file
return(null);
}

function Ticker

while (!end of file)
{
display next item
}

LoadFile()
return(null);

function Display()
Ticker()
return(null);

It looks horrible and the syntax is pants, but the idea is that it runs 
the function Display, which calls Ticker.  That displays each item until 
the end of the file is reached, then it runs the LoadFile function, 
ensuring that every time it runs through the file once, it reloads it in 
case it's changed.  It then returns to the Ticker which returns to 
Display and it starts all over again.

One slightly off the wall idea I just thought of (don't know if it's 
possible?).  When the script goes to the LoadFile function, read in the 
Last Updated date of the file, and if it's within the length of time the 
script takes to run, then reload the file.

Sorry not to be any use with the coding but maybe somebody else can put 
these suggestions into code, assuming they're any good :)

Kind regards,

Julian

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html