X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fweb%2Flookup;h=2f67760c487d6f1281b37bcb819ca6a7b2dd3d01;hb=a1fb96b672d234f5961a397215c19c2c631c5cc3;hp=1b85ecc8b9d06b9dc5ba96b14b63e4cac99501c0;hpb=72587d0d7358ca77ecd0ede859abba7f89b1d9d2;p=ypp-sc-tools.db-live.git diff --git a/yarrg/web/lookup b/yarrg/web/lookup index 1b85ecc..2f67760 100755 --- a/yarrg/web/lookup +++ b/yarrg/web/lookup @@ -57,7 +57,35 @@ my %styles; Before => 'Query: ', Values => [ [ 'route', 'Trades for route' ], [ 'commod', 'Prices for commodity' ], + [ 'offers', 'Offers at location' ], + [ 'routesearch', 'Find profitable route' ], [ '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, + }, { Name => 'RouteSearchType', + Before => 'Type of routes to search for: ', + Values => [ [ 0, 'Open-ended' ], + [ 1, 'Circular' ], + ], + QuerySpecific => 1, }); foreach my $var (@vars) { @@ -98,12 +126,34 @@ $ours % } -<% ucfirst $ahtml{Query} %> - YARRG +<% ucfirst $ahtml{Query} %> - YARRG + +<&| script &> + function register_onload(f) { + var previous_onload= window.onload; + window.onload= function() { + if (previous_onload) previous_onload(); + f(); + }; + } + + YARRG - Yet Another Revenue Research Gatherer | +introduction +| documentation +| +development

<%perl> @@ -115,7 +165,14 @@ foreach my $var (@vars) { foreach my $var (keys %ARGS) { next unless $var =~ - m/^(?:(?:route|commod)string|islandid\d|archipelago\d|debug)$/; + m/^(?: (?:route|commod|capacity|capital|island)string | + lossperleague | distance | + commodid | + islandid \d | + archipelago \d | + debug | + [RT]\w+ + )$/x; my $val= $ARGS{$var}; next if $val eq 'none'; $queryqf{$var}= $val; @@ -127,7 +184,8 @@ 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}; @@ -154,19 +212,38 @@ foreach my $var (@vars) { $cvalix++; } print "

\n\n"; +}; + +my $prselector= sub { + my ($name)= @_; + foreach my $var (@vars) { + if ($var->{Name} eq $name) { + $prselector_core->($var); + return; + } + } + die $name; +}; + +foreach my $var (@vars) { + next if $var->{QuerySpecific}; + $prselector_core->($var); } #---------- initial checks, startup, main entry form ---------- die if $styles{Query} =~ m/[^a-z]/; -dbw_connect($styles{Ocean}); +my $mydbh; +my $dbh= ($mydbh= dbw_connect($styles{Ocean})); my $results_head_done=0; my $someresults= sub { return if $results_head_done; $results_head_done=1; - print "\n

Results

\n"; + my ($h)= @_; + $h= 'Results' if !$h; + print "\n

$h

\n"; }; @@ -176,7 +253,9 @@ $debug => 0
-<& "query_$styles{Query}", %baseqf, %queryqf, %styles, quri => $quri, +<& "query_$styles{Query}", %baseqf, %queryqf, %styles, + quri => $quri, dbh => $dbh, queryqf => \%queryqf, allargs => \%ARGS, + prselector => $prselector, someresults => $someresults, emsgokorprint => sub { my ($emsg) = @_; @@ -215,3 +294,8 @@ use HTML::Entities; use URI::Escape; +<%cleanup> + +$mydbh->rollback() if $mydbh; + +