chiark / gitweb /
Use POST for routetrade update to avoid overly long URLs due to many tickyboxes
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Wed, 26 Aug 2009 00:49:33 +0000 (01:49 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Wed, 26 Aug 2009 00:49:33 +0000 (01:49 +0100)
yarrg/TODO
yarrg/web/query_route

index 6c9e31cd56a5cd5eb16b6acd9732fc4e0e7e4f90..e3ecc68b1f1d6ed31768ffa94a602abc3fae359f 100644 (file)
@@ -28,8 +28,6 @@ circular routes are treated as complex eg
 
 onload thing broken, need proper framework
 
-use POST for routetrade update
-
 dropdowns are broken sometimes
 
 initial/final stocks feature
index be1196e899ab3fa8e99c8c9b975a59b4ff6ebc10..ee457f57abd41502ad3d54f58385b16638e8ced5 100644 (file)
@@ -49,6 +49,16 @@ my @islandids;
 my %islandid2;
 
 my $qa= \%ARGS;
+
+my $be_post;
+my $startform= sub {
+       ($be_post)= @_;
+</%perl>
+<form action="<% $quri->() |h %>" method="<% $be_post ? 'post' : 'get' %>">
+<%perl>
+};
+my $goupdate= sub { $be_post ? 'Update' : 'Go' };
+
 </%perl>
 
 <h1>Specify route</h1>
@@ -61,7 +71,7 @@ my $qa= \%ARGS;
 Enter route (islands, or archipelagoes, separated by |s or commas;
  abbreviations are OK):<br>
 
-<form action="<% $quri->() |h %>" method="get">
+% $startform->($routestring =~ m/\S/);
 
 <&| qtextstring, qa => $qa, dbh => $dbh,
     thingstring => 'routestring', emsgstore => \$emsg,
@@ -76,6 +86,11 @@ 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));
+
 <%perl>
 my ($sth,$row);
 my @archlistdata;
@@ -165,7 +180,7 @@ function ms_Setarch(dd) {
 
 % } #---------- end of dropdowns, now common middle of page code ----------
 
-<input type=submit name=submit value="Go">
+<input type=submit name=submit value="<% $goupdate->() %>">
 % my $ours= sub { $_[0] =~ m/^island|^archipelago|^routestring|^[RT]/; };
 <& "lookup:formhidden", ours => $ours &>