X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.web-live.git;a=blobdiff_plain;f=yarrg%2Fweb%2Fquery_route;h=e9e358a433bc928b325a773651441b9ee25971d4;hp=dc1ebc9917608eaf7a596e7d3eaf95e58165676a;hb=98610392fde2add293bee6199f2de1d6f88559d8;hpb=dfae6286760f90eec22d236d57014f68149161ad diff --git a/yarrg/web/query_route b/yarrg/web/query_route index dc1ebc9..e9e358a 100644 --- a/yarrg/web/query_route +++ b/yarrg/web/query_route @@ -35,15 +35,19 @@ <%args> $quri -$qa +$dbh $routestring => ''; +$someresults +$emsgokorprint -<%perl> +<%perl> +my $emsg; my @archipelagoes; my @islandids; my %islandid2; +my $qa= \%ARGS; %#---------- textbox, user enters route as string ---------- @@ -51,16 +55,26 @@ my %islandid2;

Specify route

+Enter route (islands, or archipelagoes, separated by |s or commas; + abbreviations are OK):
+
-<&| 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..." ] ]; @@ -78,8 +92,6 @@ my $optionlistmap= sub { return $out; }; -my $dbh= dbw_connect($qa->{Ocean}); - $sth= $dbh->prepare("SELECT DISTINCT archipelago FROM islands ORDER BY archipelago;"); $sth->execute(); @@ -110,8 +122,6 @@ foreach my $arch (keys %islandlistdata) { - - <&| script &> ms_lists= <% to_json_protecttags(\%resetislandlistdata) %>; function ms_Setarch(dd) { @@ -153,38 +163,14 @@ function ms_Setarch(dd) { % } #---------- end of dropdowns, now common middle of page code ---------- +% my $ours= sub { $_[0] =~ m/^island|^archipelago|^routestring/; }; +<& "lookup:formhidden", ours => $ours &>
<%perl> -#========== result computations ========== +#========== results ========== -my $results_head; -$results_head= sub { - print "

Results

\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) = @_; @@ -201,7 +187,7 @@ for my $dd (0..$qa->{Dropdowns}-1) { my $ii= $islandid2{$island}; my $iarch= $ii->{Arch}; if ($iarch ne $arch) { - $results_head->(); + $someresults->(); Specified archipelago <% $arch %> but island <% $ii->{Name} %> @@ -214,12 +200,12 @@ for my $dd (0..$qa->{Dropdowns}-1) { push @islandids, $island; } -}#---------- result processing, common stuff % if (@islandids) { -% $results_head->(); - -<& routetrade, islandids => \@islandids, archipelagoes => \@archipelagoes &> - +% $someresults->(); +<& routetrade, + dbh => $dbh, + islandids => \@islandids, + archipelagoes => \@archipelagoes &> % }