To change the content on the browser side, you need
some kind of client-side technology, such as ECMA script
("Javascript") or a plugin. However, what you describe
sounds to me like separate pages. Is there some way your
script can initially send only the first page, but
include a link (and maybe an HTTP refresh) back to
the script with an additional parameter that indicates
to print the second page, the third page, or whatever?
So, if there's no page set, you send page 1 (with a
link with page=2), but if the query string says
page=3 you send page 3 and a link with page=4. This
is the way all the major search engines do it, I think.
If the query string says page=n, you send page n with
a link to page=n+1
$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}}
split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
| [reply] [d/l] |
You could "poll" from the client-side with Javascript ...
...
my $JS<<END;
function goThere () {
document.location="$yourURL";
}
function delay () {
setInterval ( "goThere()", 6000 );
}
END
...
print start_html( ..., -script=>$JS, ... );
...
Plankton: 1% Evil, 99% Hot Gas. |
| [reply] [d/l] |
OK, yes it could be done that way. But why would you? Using your method assumes that JavaScript is enabled in the browser. My WEB sites record enough browsers without JS activated to make it worth our while to NOT use JS. Only place we use it is for some form validation, it makes things faster on the client side, but we always have ful validation in our Perl scripts to do two things:
- Make sure our forms and JS are not tampered with
- Validate where client has no JS.
By using your method you would exclude a fair percentage of browsers.
jdtoronto
| [reply] |
I would have to say the way I could see this being done would be to inbed a meta refresh tag into the html output and just point to some sort of incremental page system.I.E. bla.html -> bla1.html -> bla2.html and so on.
-Stephen | [reply] |
| [reply] |
I agree that it would make more sense to have the perl handle this, but I am not quit sure how I would do it. Let me do some diggin and see what I can come up with, also if you find a good solution in the meantime please share with me as I would be very curious as to what you came up with.
Stephen
| [reply] |
I have a couple of examples that might help explain where I'm at and where I need to get to.
The two examples, attached to this e-mail, represent the development path of the tool I created.
Script "threadTest2.pl" provides the results in the same fashion as your stock ticker. This is easy to send the new information to the user's browser.
Script "threadTest3.pl" displays the items as a group every time an item changes. I can send these groups to the screen with no problem.
What I want to do is find a way to redraw the screen each time a new group is sent to the browser, so it would appear that only the status of the items is changing.
My first thought was to refresh also, but since this is a live program, that is not an option since it would restart the program.
The eventual goal is to put a cancel button below the displayed group that the user could press if the process is taking to long. The program would then cancel all threads that have not completed and continue to process and display the results from the finished threads.
Any thoughts, help or advice would greatly be appreciated.
Thanks,
Doug
### Program: threadTest2.pl ###
use threads;
use threads::shared;
use CGI::Push qw/:standard/;
# Shared variables
my $progressThread1 : shared = 0;
my $progressThread2 : shared = 0;
my $progressThread3 : shared = 0;
my $progressThread4 : shared = 0;
my $progressThread5 : shared = 0;
# Arrary of progress text
@progress = (
'No Activity....',
'Connecting.....',
'Searching......',
'Parsing........',
'Finished.......',
'Error..........',
);
# Create threads
$thr1 = threads->new(\&thread1);
$thr2 = threads->new(\&thread2);
$thr3 = threads->new(\&thread3);
$thr4 = threads->new(\&thread4);
$thr5 = threads->new(\&thread5);
# Do not end program until all threads have finished
$thr1->join();
$thr2->join();
$thr3->join();
$thr4->join();
$thr5->join();
sub thread1 {
sleep 6;
screenDisplay( 1, 1 );
sleep 2;
screenDisplay( 1, 2 );
sleep 4;
screenDisplay( 1, 3 );
sleep 5;
screenDisplay( 1, 4 );
}
sub thread2 {
sleep 8;
screenDisplay( 2, 1);
sleep 2;
screenDisplay( 2, 2 );
sleep 4;
screenDisplay( 2, 3 );
sleep 5;
screenDisplay( 2, 4 );
}
sub thread3 {
sleep 3;
screenDisplay( 3, 1 );
sleep 2;
screenDisplay( 3, 2 );
sleep 4;
screenDisplay( 3, 3 );
sleep 5;
screenDisplay( 3, 4 );
}
sub thread4 {
sleep 10;
screenDisplay( 4, 1 );
sleep 2;
screenDisplay( 4, 2 );
sleep 4;
screenDisplay( 4, 3 );
sleep 5;
screenDisplay( 4, 4 );
}
sub thread5 {
sleep 1;
screenDisplay( 5, 1 );
sleep 2;
screenDisplay( 5, 2 );
sleep 4;
screenDisplay( 5, 3 );
sleep 5;
screenDisplay( 5, 4 );
}
sub screenDisplay {
my ( $thread, $status ) = @_;
print $progress[$status], "Thread: $thread\n";
return undef;
}
### Program: threadTest3.pl ###
use threads;
use threads::shared;
use CGI::Push qw/:standard/;
# Shared variables
my $progressThread1 : shared = 0;
my $progressThread2 : shared = 0;
my $progressThread3 : shared = 0;
my $progressThread4 : shared = 0;
my $progressThread5 : shared = 0;
# Arrary of site names
@sites = (
'',
'Site One',
'Site Two',
'Site Three',
'Site Four',
'Site Five',
);
# Arrary of progress text
@progress = (
'No Activity....',
'Connecting.....',
'Searching......',
'Parsing........',
'Finished.......',
'Error..........',
);
# Create threads
$thr1 = threads->new(\&thread1);
$thr2 = threads->new(\&thread2);
$thr3 = threads->new(\&thread3);
$thr4 = threads->new(\&thread4);
$thr5 = threads->new(\&thread5);
# Do not end program until all threads have finished
$thr1->join();
$thr2->join();
$thr3->join();
$thr4->join();
$thr5->join();
sub thread1 {
sleep 6; $progressThread1 = 1;
screenDisplay();
sleep 2; $progressThread1 = 2;
screenDisplay();
sleep 4; $progressThread1 = 3;
screenDisplay();
sleep 5; $progressThread1 = 4;
screenDisplay();
}
sub thread2 {
sleep 8; $progressThread2 = 1;
screenDisplay();
sleep 2; $progressThread2 = 2;
screenDisplay();
sleep 4; $progressThread2 = 3;
screenDisplay();
sleep 5; $progressThread2 = 4;
screenDisplay();
}
sub thread3 {
sleep 3; $progressThread3 = 1;
screenDisplay();
sleep 2; $progressThread3 = 2;
screenDisplay();
sleep 4; $progressThread3 = 3;
screenDisplay();
sleep 5; $progressThread3 = 4;
screenDisplay();
}
sub thread4 {
sleep 10; $progressThread4 = 1;
screenDisplay();
sleep 2; $progressThread4 = 2;
screenDisplay();
sleep 4; $progressThread4 = 3;
screenDisplay();
sleep 5; $progressThread4 = 4;
screenDisplay();
}
sub thread5 {
sleep 1; $progressThread5 = 1;
screenDisplay();
sleep 2; $progressThread5 = 2;
screenDisplay();
sleep 4; $progressThread5 = 3;
screenDisplay();
sleep 5; $progressThread5 = 4;
screenDisplay();
}
sub screenDisplay {
print $progress[$progressThread1], $sites[1], "\n";
print $progress[$progressThread2], $sites[2], "\n";
print $progress[$progressThread3], $sites[3], "\n";
print $progress[$progressThread4], $sites[4], "\n";
print $progress[$progressThread5], $sites[5], "\n\n";
}
20030926 Edit by Corion: Fixed formatting | [reply] [d/l] |
Check out http://openthought.net/ and especially the demo.
Don't assume javascript is enabled, demand it :)
MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!" | I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README). | ** The third rule of perl club is a statement of fact: pod is sexy. |
| [reply] |