X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-test.git;a=blobdiff_plain;f=yarrg%2Fweb%2Flookup;h=15c52067f45cfeb40d090a8c86e63903f9d83ff2;hp=f59d6cca4a98328986a7f9930f8e40e20e6e777b;hb=70abc75f17b353bb3f3e112d949056e753b7ecb3;hpb=5be99f4d3905725a93bc9a30f5c230d6c9d6a8ce diff --git a/yarrg/web/lookup b/yarrg/web/lookup old mode 100644 new mode 100755 index f59d6cc..15c5206 --- a/yarrg/web/lookup +++ b/yarrg/web/lookup @@ -1,44 +1,43 @@ -%# This is part of the YARRG website. YARRG is a tool and website -%# for assisting players of Yohoho Puzzle Pirates. -%# -%# Copyright (C) 2009 Ian Jackson -%# Copyright (C) 2009 Clare Boothby -%# -%# YARRG's client code etc. is covered by the ordinary GNU GPL (v3 or later). -%# The YARRG website is covered by the GNU Affero GPL v3 or later, which -%# basically means that every installation of the website will let you -%# download the source. -%# -%# This program is free software: you can redistribute it and/or modify -%# it under the terms of the GNU Affero General Public License as -%# published by the Free Software Foundation, either version 3 of the -%# License, or (at your option) any later version. -%# -%# This program is distributed in the hope that it will be useful, -%# but WITHOUT ANY WARRANTY; without even the implied warranty of -%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%# GNU Affero General Public License for more details. -%# -%# You should have received a copy of the GNU Affero General Public License -%# along with this program. If not, see . -%# -%# Yohoho and Puzzle Pirates are probably trademarks of Three Rings and -%# are used without permission. This program is not endorsed or -%# sponsored by Three Rings. -%# -%# -%# This Mason component generates the main `lookup' page, including -%# all the entry boxes etc. for every query. -%# +<%doc> + + This is part of the YARRG website. YARRG is a tool and website + for assisting players of Yohoho Puzzle Pirates. + + Copyright (C) 2009 Ian Jackson + Copyright (C) 2009 Clare Boothby + + YARRG's client code etc. is covered by the ordinary GNU GPL (v3 or later). + The YARRG website is covered by the GNU Affero GPL v3 or later, which + basically means that every installation of the website will let you + download the source. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + + Yohoho and Puzzle Pirates are probably trademarks of Three Rings and + are used without permission. This program is not endorsed or + sponsored by Three Rings. + + + This Mason component generates the main `lookup' page, including + all the entry boxes etc. for every query. + + + <%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 ---------- @@ -57,7 +56,40 @@ my %islandid2; }, { Name => 'Query', 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' ], + [ 2, "Also be cautious about stalls'". + " poe reserves", + '[?]' ] + ], + QuerySpecific => 1, + }, { Name => 'RouteSearchType', + Before => 'Type of routes to search for: ', + Values => [ [ 0, 'Open-ended' ], + [ 1, 'Circular' ], + [ 2, 'Specific destination' ], + ], + QuerySpecific => 1, }); foreach my $var (@vars) { @@ -70,36 +102,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]; } } -<% ucfirst $ahtml{Query} %> - YARRG -YARRG - - Yet Another Revenue Research Gatherer -| -documentation +<%shared> +my %baseqf; +my %queryqf; + + +<%method formhidden> +<%args> +$ours + +% foreach my $n (keys %baseqf, keys %queryqf) { +% next if $ours->($n); +% my $v= exists $baseqf{$n} ? $baseqf{$n} : $queryqf{$n}; + value="<% $v |h %>"> +% } + + +<% ucfirst $ahtml{Query} %> - YARRG + +<&| script &> + function register_onload(f) { + var previous_onload= window.onload; + window.onload= function() { + if (previous_onload) previous_onload(); + f(); + }; + } + + + +% if (!printable($m)) { + +
% } -% } elsif ($a{Query} eq 'age') { -% ########### query `age' ########## - -

Market data age

-<& dataage, %baseqf, %queryqf &> - -% } ########## end of `age' query ########## +<& "query_$styles{Query}", %baseqf, %queryqf, %styles, + quri => $quri, dbh => $dbh, + baseqf => \%baseqf, queryqf => \%queryqf, allargs => \%ARGS, + prselector => $prselector, + someresults => $someresults, + emsgokorprint => sub { + my ($emsg) = @_; + return 1 unless defined $emsg and length $emsg; + $someresults->(); + print $emsg; + return 0; + } + &> %#---------- debugging and epilogue ---------- % if ($debug) { -

+

 Debug log:
 
+
% } - + <& footer &> @@ -408,6 +300,10 @@ function debug (m) { use CommodsWeb; use HTML::Entities; use URI::Escape; -use JSON; +<%cleanup> + +$mydbh->rollback() if $mydbh; + +