X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fweb%2Fpirate-route;h=154b37ddee30b5d7bca1aac22c8aa2a46bc25f3f;hb=5cc1eb0200564bcc8d67ecf4250afebaaeff2eff;hp=612c577287615e9f7aa99a56e5f6dcdc196b477b;hpb=9ad85b94399ad653e1d10fd18500a9e2205f032d;p=ypp-sc-tools.db-live.git diff --git a/yarrg/web/pirate-route b/yarrg/web/pirate-route index 612c577..154b37d 100644 --- a/yarrg/web/pirate-route +++ b/yarrg/web/pirate-route @@ -4,6 +4,11 @@ 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] }, @@ -56,6 +61,7 @@ foreach my $var (@vars) { } } my $uri= URI->new($m->current_comp()->name()); + $qf{'debug'}=1 if $debug; $uri->query_form(%qf); print ''; $after= ''; @@ -63,9 +69,11 @@ 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(); @@ -73,11 +81,16 @@ 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 |s or commas; abbreviations are OK):
@@ -95,8 +108,7 @@ function tr_Later(){ } function tr_Needed(){ window.clearTimeout(tr_timeout); - //tr_element= document.getElementsByName('routestring').item(0); - //alert(tr_element.name); + tr_element= document.getElementById('routestring'); tr_needed= tr_element.value; tr_Request(); } @@ -113,79 +125,80 @@ function tr_Ready() { if (tr_request.readyState != 4) return; if (tr_request.status == 200) { response= tr_request.responseText; - //alert('got [[ '+response+' ]]'); eval('results='+response); - toedit= document.getElementsByName('routeresults').item(0); - toedit.innerHTML= results['show']; + toedit= document.getElementById('routeresults'); + toedit.innerHTML= results.show; } tr_request= false; tr_Request(); } -
-
 

+
+
 

-% } else { +% } else { #---------- dropdowns, user selects from menus ---------- <%perl> -my $sth=$dbh->prepare("SELECT islandid,islandname,archipelago - 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=''; -my %archmap=(); + while ($row=$sth->fetchrow_arrayref) { - $islandlistdata.= + my ($arch)= @$row; + $archlistdata.= sprintf('', - map { encode_entities($_) } @$row[0..1]); - $archmap{$row->[0]}= $row->[2]; + map { encode_entities($_) } ($arch,$arch)); + $islandlistdata{$arch}= <Whole arch +END } -$sth=$dbh->prepare("SELECT DISTINCT archipelago FROM islands - ORDER BY archipelago;"); +$sth= $dbh->prepare("SELECT islandid,islandname,archipelago + FROM islands + ORDER BY islandname;"); $sth->execute(); -my $archlistdata=''; while ($row=$sth->fetchrow_arrayref) { - $archlistdata.= - sprintf('', - map { encode_entities($_) } (@$row, @$row)); + 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) { - % } @@ -193,17 +206,34 @@ function setarch(dd) { % 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;