</%doc>
<%args>
$quri
-$qa
+$dbh
$routestring => '';
+$someresults
+$emsgokorprint
</%args>
-<%perl>
+<%perl>
+my $emsg;
my @archipelagoes;
my @islandids;
my %islandid2;
+my $qa= \%ARGS;
</%perl>
%#---------- textbox, user enters route as string ----------
<h1>Specify route</h1>
+Enter route (islands, or archipelagoes, separated by |s or commas;
+ abbreviations are OK):<br>
+
<form action="<% $quri->() |h %>" method="get">
-<&| qtextstring, qa => $qa, thingstring => 'routestring' &>
+<&| qtextstring, qa => $qa, dbh => $dbh,
+ thingstring => 'routestring', emsgstore => \$emsg,
+ perresult => sub {
+ my ($canonname, $island, $arch) = @_;
+ push @islandids, $island;
+ push @archipelagoes, defined $island ? undef : $arch;
+ }
+ &>
size=80
</&>
% } else { #---------- dropdowns, user selects from menus ----------
<%perl>
-my ($sth,$row);;
+my ($sth,$row);
my @archlistdata;
my %islandlistdata;
$islandlistdata{'none'}= [ [ "none", "Select island..." ] ];
return $out;
};
-my $dbh= dbw_connect($qa->{Ocean});
-
$sth= $dbh->prepare("SELECT DISTINCT archipelago FROM islands
ORDER BY archipelago;");
$sth->execute();
$optionlistmap->($islandlistdata{$arch}, '');
}
-$dbh->rollback();
-
</%perl>
-<input type=hidden name=dropdowns value="<% $qa->{Dropdowns} |h %>">
-
<&| script &>
ms_lists= <% to_json_protecttags(\%resetislandlistdata) %>;
function ms_Setarch(dd) {
% } #---------- end of dropdowns, now common middle of page code ----------
<input type=submit name=submit value="Go">
+% my $ours= sub { $_[0] =~ m/^island|^archipelago|^routestring/; };
+<& "lookup:formhidden", ours => $ours &>
</form>
<%perl>
-#========== result computations ==========
+#========== results ==========
-my $results_head;
-$results_head= sub {
- print "<h1>Results</h1>\n";
- $results_head= sub { };
-};
-
-#---------- result computation - textstring ----------
-if (!$qa->{Dropdowns}) {
- if (length $routestring) {
- $results_head->();
- my ($emsg,$canonstring,$results)= $m->comp('check_routestring',
- ocean => $qa->{Ocean},
- string => $routestring,
- format => 'return'
- );
- if (length $emsg) {
- print encode_entities($emsg);
- } else {
- foreach my $entry (@$results) {
- push @archipelagoes,
- defined $entry->[1] ? undef : $entry->[0];
- push @islandids, $entry->[1];
- }
- }
- }
-
-} else { #---------- results - dropdowns ----------
+$emsgokorprint->($emsg) or @islandids=();
my $argorundef= sub {
my ($dd,$base) = @_;
my $ii= $islandid2{$island};
my $iarch= $ii->{Arch};
if ($iarch ne $arch) {
- $results_head->();
+ $someresults->();
</%perl>
Specified archipelago <% $arch %> but
island <% $ii->{Name} %>
push @islandids, $island;
}
-}#---------- result processing, common stuff
</%perl>
% if (@islandids) {
-% $results_head->();
-
-<& routetrade, islandids => \@islandids, archipelagoes => \@archipelagoes &>
-
+% $someresults->();
+<& routetrade,
+ dbh => $dbh,
+ islandids => \@islandids,
+ archipelagoes => \@archipelagoes &>
% }