From: Ian Jackson Date: Wed, 26 Aug 2009 02:05:21 +0000 (+0100) Subject: Fix dropdowns for route and commod X-Git-Tag: 3.4~89 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.main.git;a=commitdiff_plain;h=017f4432a9bb472f61ab94c10b775e64d86ca391 Fix dropdowns for route and commod --- diff --git a/yarrg/TODO b/yarrg/TODO index e6d969e..f21dabf 100644 --- a/yarrg/TODO +++ b/yarrg/TODO @@ -23,8 +23,6 @@ commodity mass/volume in live database WEBSITE ------- -dropdowns are broken sometimes - initial/final stocks feature adjustable potential cost of losses (rather than fixed 1e-BIG per league) diff --git a/yarrg/web/lookup b/yarrg/web/lookup index 4dbd755..8fb3bb1 100755 --- a/yarrg/web/lookup +++ b/yarrg/web/lookup @@ -154,6 +154,7 @@ foreach my $var (@vars) { foreach my $var (keys %ARGS) { next unless $var =~ m/^(?: (?:route|commod)string | + commodid | islandid \d | archipelago \d | debug | diff --git a/yarrg/web/query_commod b/yarrg/web/query_commod index 9575260..c87b440 100644 --- a/yarrg/web/query_commod +++ b/yarrg/web/query_commod @@ -36,6 +36,7 @@ <%args> $quri $dbh +$commodid => undef; $commodstring => ''; $prselector $someresults @@ -44,7 +45,7 @@ $emsgokorprint <%perl> my $emsg; -my ($commodname,$commodid); +my ($commodname,$cmid); my $qa= \%ARGS; @@ -54,23 +55,34 @@ my $qa= \%ARGS; % $prselector->('BuySell'); % $prselector->('ShowBlank'); +
+ %#---------- textbox, user enters route as string ---------- % if (!$qa->{Dropdowns}) { Enter commodity (abbreviations are OK):
- - <&| qtextstring, qa => $qa, dbh => $dbh, thingstring => 'commodstring', emsgstore => \$emsg, - perresult => sub { ($commodname,$commodid)= @_; } + perresult => sub { ($commodname,$cmid)= @_; } &> size=80 % } else { #---------- dropdowns, user selects from menus ---------- -Not yet implemented. +% my $sth= $dbh->prepare("SELECT commodname,commodid FROM commods +% ORDER BY commodname"); +% $sth->execute(); +% my $row; + % } #---------- end of dropdowns, now common middle of page code ---------- @@ -83,8 +95,8 @@ Not yet implemented. %#========== results ========== <%perl> -$emsgokorprint->($emsg) or $commodid=undef; -return unless defined $commodid; +$emsgokorprint->($emsg) or $cmid=undef; +return unless defined $cmid; $someresults->(); #---------- actually compute the results and print them ---------- @@ -131,13 +143,13 @@ foreach my $bs (split /_/, $ARGS{BuySell}) { +/-10% Any -% $islands->execute($commodid); +% $islands->execute($cmid); % my $island; % my %ts_sortkeys; % my $rowix= 0; % while ($island= $islands->fetchrow_hashref) { % my $islandid= $island->{'islandid'}; -% $offers->execute($commodid, $islandid); +% $offers->execute($cmid, $islandid); % my ($offer, $bestprice, $marginal, @beststalls); % my $tqty= $island->{'tqty'}; % my $cqty= ''; @@ -176,7 +188,7 @@ foreach my $bs (split /_/, $ARGS{BuySell}) { % $stallname= sprintf "%d offers", scalar @beststalls; % } % -% $cqty == $tqty or die "$bs $cqty $tqty $commodid $islandid "; +% $cqty == $tqty or die "$bs $cqty $tqty $cmid $islandid "; class="<% 'datarow'.($rowix & 1) %>"> <% $s->[0]= $island->{'archipelago'} |h %> <% $s->[1]= $island->{'islandname'} |h %> diff --git a/yarrg/web/query_route b/yarrg/web/query_route index ee457f5..393e7a6 100644 --- a/yarrg/web/query_route +++ b/yarrg/web/query_route @@ -86,10 +86,10 @@ Enter route (islands, or archipelagoes, separated by |s or commas; % } else { #---------- dropdowns, user selects from menus ---------- -$startform->(grep { - defined %ARGS{"archipelago$dd"} || - defined %ARGS{"islandid$dd"} - } (0..$qa->{Dropdowns}-1)); +% $startform->(grep { +% defined $ARGS{"archipelago$_"} || +% defined $ARGS{"islandid$_"} +% } (0..$qa->{Dropdowns}-1)); <%perl> my ($sth,$row);