From 43f6ebdd538a6e75b3d6c43d0ce18b81c972ffd7 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 12 Aug 2009 13:51:41 +0100 Subject: [PATCH] route menu selection mode seems to work --- yarrg/web/pirate-route | 131 +++++++++++++++++++++++++++++++++-------- 1 file changed, 106 insertions(+), 25 deletions(-) diff --git a/yarrg/web/pirate-route b/yarrg/web/pirate-route index 0f2fff7..9dfab7e 100644 --- a/yarrg/web/pirate-route +++ b/yarrg/web/pirate-route @@ -1,5 +1,14 @@ Specify route + + <%perl> my %a; my @vars; @@ -56,6 +65,7 @@ foreach my $var (@vars) { } } my $uri= URI->new($m->current_comp()->name()); + $qf{'debug'}=1 if $debug; $uri->query_form(%qf); print ''; $after= ''; @@ -73,6 +83,9 @@ db_setocean($a{Ocean}); db_connect(); +<%args> +$debug => 0 +

Specify route

@@ -114,7 +127,7 @@ function tr_Ready() { response= tr_request.responseText; eval('results='+response); toedit= document.getElementById('routeresults'); - toedit.innerHTML= results['show']; + toedit.innerHTML= results.show; } tr_request= false; tr_Request(); @@ -128,46 +141,67 @@ function tr_Ready() { % } else { <%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; } + + +% if (0) { var nodes= select.getElementsByTagName('option'); +alert(ms_lists[dd]); for (var i=0; i +% } + +% if (0) { + +% } - +
% for my $dd (0..$a{Dropdowns}-1) { - % } @@ -190,17 +240,48 @@ function setarch(dd) { % for my $dd (0..$a{Dropdowns}-1) { + +<% $islandlistdata{'none'} %> % }
+
+ + + +% if (0) { + +% } + % } +% if ($debug) { +

+

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