X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-live.git;a=blobdiff_plain;f=yarrg%2Fweb%2Fpirate-route;h=84b61e40acc00b29865ed85466d4bd180cf60c2f;hp=f58d47c20f450041eb39d2b13ee3d8784b4f1442;hb=6fed4d2eccc640ca025f66c63cb7ac4d4423e6fb;hpb=007700c6236644463a0e78724b8260f14be4bedd diff --git a/yarrg/web/pirate-route b/yarrg/web/pirate-route index f58d47c..84b61e4 100644 --- a/yarrg/web/pirate-route +++ b/yarrg/web/pirate-route @@ -4,10 +4,15 @@ my %a; my @vars; +#---------- "mode" argument parsing and mode menu at top of page ---------- + +# for debugging, invoke as +# http://www.chiark.greenend.org.uk/ucgi/~clareb/mason/pirates/pirate-route?debug=1 + @vars= ({ Name => 'Ocean', Before => 'Ocean: ', CmpCanon => sub { ucfirst lc $_[0] }, - Values => [ qw(Midnight Ice) ] + Values => [ ocean_list() ] }, { Name => 'Dropdowns', Before => 'Interface: ', CmpCanon => sub { !!$_[0] }, @@ -55,7 +60,8 @@ foreach my $var (@vars) { $qf{$n}= $value; } } - my $uri= URI->new($self_url); + my $uri= URI->new($m->current_comp()->name()); + $qf{'debug'}=1 if $debug; $uri->query_form(%qf); print ''; $after= ''; @@ -63,98 +69,170 @@ foreach my $var (@vars) { print $html, $after; $cvalix++; } - print '

'; + print "

\n\n"; } +#---------- initial checks, startup, main entry form ---------- + +die "unknown ocean $a{Ocean} ?" + unless grep { $_ eq $a{Ocean} } ocean_list(); + db_setocean($a{Ocean}); db_connect(); +<%args> +$debug => 0 +

Specify route

+%#---------- textbox, user enters route as string ---------- % if (!$a{Dropdowns}) { -Enter route (islands, or archipelagoes, separated by commas; + +Enter route (islands, or archipelagoes, separated by |s or commas; abbreviations are OK):
-
-

+
+
 

-% } else { +% } else { #---------- dropdowns, user selects from menus ---------- <%perl> -my $sth=$dbh->prepare("SELECT islandid,islandname - FROM islands - ORDER BY islandname;"); +my ($sth,$row);; +my $archlistdata=''; +my %islandlistdata; +$islandlistdata{'none'}= <Select island... +END + +$sth= $dbh->prepare("SELECT DISTINCT archipelago FROM islands + ORDER BY archipelago;"); $sth->execute(); -my $row; -my $islandlistdata=''; + while ($row=$sth->fetchrow_arrayref) { - $islandlistdata.= + my ($arch)= @$row; + $archlistdata.= sprintf('', - map { encode_entities($_) } @$row); + map { encode_entities($_) } ($arch,$arch)); + $islandlistdata{$arch}= <Whole arch +END +} + +$sth= $dbh->prepare("SELECT islandid,islandname,archipelago + FROM islands + ORDER BY islandname;"); +$sth->execute(); + +while ($row=$sth->fetchrow_arrayref) { + my $arch= $row->[2]; + my $here= sprintf('', + map { encode_entities($_) } @$row[0..1]); + $islandlistdata{'none'} .= $here; + $islandlistdata{$arch} .= $here; } + - + + +
+ + +% for my $dd (0..$a{Dropdowns}-1) { + +% } + + % for my $dd (0..$a{Dropdowns}-1) { +<% $islandlistdata{'none'} %> % } +
+
-% } + +% } #---------- end of dropdowns, now common code ---------- +% if ($debug) { +

+

+Debug log:
+
+% } + + + <%init> use CommodsWeb; use HTML::Entities;