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=18c3ecb1390af1f2d3a3fc4f2108d2a64f5c90ce;hp=ea94d61c8f20ddf3428f2d873232c4e2f1d27557;hb=4311ae355f0a94637c94d1d02a6edcbe65bebaa7;hpb=c5b3ac45babf8012719dfb7eafd0cfa9d9eddff0 diff --git a/yarrg/web/query_route b/yarrg/web/query_route index ea94d61..18c3ecb 100644 --- a/yarrg/web/query_route +++ b/yarrg/web/query_route @@ -35,32 +35,49 @@ <%args> $quri -$qa +$dbh +$prselector $routestring => ''; +$someresults +$emsgokorprint -<%perl> +<%perl> +my $emsg; my @archipelagoes; my @islandids; my %islandid2; +my $qa= \%ARGS; +

Specify route

+ +% $prselector->('ShowStalls'); + %#---------- textbox, user enters route as string ---------- % if (!$qa->{Dropdowns}) { -

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 +95,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(); @@ -108,12 +123,8 @@ foreach my $arch (keys %islandlistdata) { $optionlistmap->($islandlistdata{$arch}, ''); } -$dbh->rollback(); - - - <&| script &> ms_lists= <% to_json_protecttags(\%resetislandlistdata) %>; function ms_Setarch(dd) { @@ -155,38 +166,13 @@ function ms_Setarch(dd) { % } #---------- end of dropdowns, now common middle of page code ---------- -
+% my $ours= sub { $_[0] =~ m/^island|^archipelago|^routestring|^rtsel[ag]_/; }; +<& "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) = @_; @@ -203,7 +189,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} %> @@ -216,12 +202,15 @@ 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, + qa => $qa + &> + % }