X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fweb%2Flookup;h=448ad6ec3441d38171735cbcbb0546b9a235ed0c;hb=6335baf49c849e16ae7845016d97bcb76d4b7cf6;hp=9206d4b536b68629c6cd93f9bc928fdffe2e4eeb;hpb=1e054798d3b98978221871919c52af06464d48f2;p=ypp-sc-tools.db-test.git diff --git a/yarrg/web/lookup b/yarrg/web/lookup index 9206d4b..448ad6e 100755 --- a/yarrg/web/lookup +++ b/yarrg/web/lookup @@ -35,14 +35,9 @@ %doc> <%perl> -my %a; my %ahtml; my @vars; - -# for output: -my @archipelagoes; -my @islandids; -my %islandid2; +my %styles; #---------- "mode" argument parsing and mode menu at top of page ---------- @@ -61,7 +56,28 @@ my %islandid2; }, { Name => 'Query', Before => 'Query: ', Values => [ [ 'route', 'Trades for route' ], + [ 'commod', 'Prices for commodity' ], [ 'age', 'Data age' ] ] + }, { Name => 'BuySell', + Before => '', + Values => [ [ 'buy_sell', 'Buy and sell' ], + [ 'sell_buy', 'Sell and buy' ], + [ 'buy', 'Buy offers only' ], + [ 'sell', 'Sell offers only' ], + ], + QuerySpecific => 1, + }, { Name => 'ShowBlank', + Before => '', + Values => [ [ 0, 'Omit islands with no offers' ], + [ 'show', 'Show all islands' ], + ], + QuerySpecific => 1, + }, { Name => 'ShowStalls', + Before => '', + Values => [ [ 0, 'Show total quantity at each price' ], + [ 1, 'Show individual stalls' ], + ], + QuerySpecific => 1, }); foreach my $var (@vars) { @@ -74,37 +90,79 @@ foreach my $var (@vars) { $val= [ $val, encode_entities($val) ]; } if (exists $ARGS{$lname}) { - $a{$name}= $ARGS{$lname}; - my @html= grep { $_->[0] eq $a{$name} } @{ $var->{Values} }; + $styles{$name}= $ARGS{$lname}; + my @html= grep { $_->[0] eq $styles{$name} } + @{ $var->{Values} }; $ahtml{$name}= @html==1 ? $html[0][1] : '???'; } else { - $a{$name}= $var->{Values}[0][0]; + $styles{$name}= $var->{Values}[0][0]; $ahtml{$name}= $var->{Values}[0][1]; } } %perl> -
<%perl> -my %baseqf; foreach my $var (@vars) { my $lname= lc $var->{Name}; next unless exists $ARGS{$lname}; $baseqf{$lname}= $ARGS{$lname}; } -my %queryqf; foreach my $var (keys %ARGS) { next unless $var =~ - m/^(?:routestring|islandid\d|archipelago\d|debug)$/; + m/^(?: (?:route|commod|capacity)string | + lossperleague | + commodid | + islandid \d | + archipelago \d | + debug | + [RT]\w+ + )$/x; my $val= $ARGS{$var}; next if $val eq 'none'; $queryqf{$var}= $val; @@ -116,11 +174,12 @@ my $quri= sub { $uri->path_query(); }; -foreach my $var (@vars) { +my $prselector_core= sub { + my ($var)= @_; my $name= $var->{Name}; my $lname= lc $var->{Name}; my $delim= $var->{Before}; - my $canon= &{$var->{CmpCanon}}($a{$name}); + my $canon= &{$var->{CmpCanon}}($styles{$name}); my $cvalix= 0; foreach my $valr (@{ $var->{Values} }) { print $delim; $delim= "\n|\n"; @@ -134,260 +193,70 @@ foreach my $var (@vars) { my %qf= (%baseqf,%queryqf); delete $qf{$lname}; $qf{$lname}= $value if $cvalix; - print ''; +%perl> + +<%perl> $after= ''; } print $html, $after; $cvalix++; } print "
\n\n"; -} - -#---------- initial checks, startup, main entry form ---------- - -dbw_connect($a{Ocean}); - -%perl> -<%args> -$debug => 0 -$routestring => '' -%args> - -
%#---------- debugging and epilogue ---------- @@ -398,14 +267,14 @@ Debug log: % } - +&script> <& footer &> @@ -413,6 +282,10 @@ function debug (m) { use CommodsWeb; use HTML::Entities; use URI::Escape; -use JSON; %init> +<%cleanup> + +$mydbh->rollback() if $mydbh; + +%cleanup>