chiark / gitweb /
clean up pirate-route
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 12 Aug 2009 13:02:41 +0000 (14:02 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 12 Aug 2009 13:02:41 +0000 (14:02 +0100)
yarrg/web/pirate-route

index 9dfab7e37309726a924f70d4f42a47cf4e86ab09..154b37ddee30b5d7bca1aac22c8aa2a46bc25f3f 100644 (file)
@@ -1,18 +1,14 @@
 <html><head><title>Specify route</title></head><body>
 
-<script type="text/javascript">
-function debug (m) {
-% if ($debug) {
-  var node= document.getElementById('debug_log');
-  node.innerHTML += "\n" + m + "\n";
-% }
-}
-</script>
-
 <%perl>
 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] },
@@ -76,6 +72,8 @@ foreach my $var (@vars) {
        print "<p>\n\n";
 }
 
+#---------- initial checks, startup, main entry form ----------
+
 die "unknown ocean $a{Ocean} ?"
        unless grep { $_ eq $a{Ocean} } ocean_list();
 
@@ -90,7 +88,9 @@ $debug => 0
 <h1>Specify route</h1>
 <form action="/ucgi/~clareb/mason/something" method="get">
 
+%#---------- textbox, user enters route as string ----------
 % if (!$a{Dropdowns}) {
+
 Enter route (islands, or archipelagoes, separated by |s or commas;
  abbreviations are OK):<br/>
 
@@ -138,7 +138,8 @@ function tr_Ready() {
  onchange="tr_Needed();"
  onkeyup="tr_Later();"><br>
 <div id="routeresults">&nbsp;</div><br/>
-% } else {
+
+% } else { #---------- dropdowns, user selects from menus ----------
 
 <%perl>
 my ($sth,$row);;
@@ -191,47 +192,12 @@ function ms_Setarch(dd) {
 }
 </script>
 
-% if (0) {
-  var nodes= select.getElementsByTagName('option');
-alert(ms_lists[dd]);
-  for (var i=0; i<nodes.length; i++) {
-    node= nodes.item(i);
-    value= node.getAttribute('value');
-    debug('ms_Setarch '+dd+' i='+i+' arch='+arch+' value='+value+'.');
-    if (value == 'none') {
-      if (arch == 'none') {
-       node.innerHTML= 'Select island ...';
-      } else {
-      }
-    } else {
-//      alert('node i='+i+' arch='+arch+' value='+value+'.');
-      node.setAttribute('disabled', !(arch=='none' || value==arch));
-    }
-  }
-}
-% }
-
-% if (0) {
-<style type="text/css">
-table
-{
-table-layout: fixed;
-color: red;
-}
-pre
-{
-color:yellow;
-}
-</style>
-% }
-
 <table style="table-layout:fixed; width:90%;">
 
 <tr>
 %      for my $dd (0..$a{Dropdowns}-1) {
 <td>
 <select  name="archipelago<% $dd %>" onchange="ms_Setarch(<% $dd %>)">
-%# style="min-width:250px;"
 <option value="none">Whole ocean</option>
 <% $archlistdata %></select></td>
 %      }
@@ -247,29 +213,7 @@ color:yellow;
 
 </table>
 
-<input type=text name=zork onclick="ms_PrepAll()">
-
-% if (0) {
-<script type="text/javascript">
-function ms_Prep(dd) {
-  //debug('ms_Prep'+dd);
-  var allnode= document.getElementsByName('islandid'+dd).item(0);
-  var newentry= {'none': allnode.innerHTML};
-  
-  ms_lists[dd]= newentry;
-}
-function ms_PrepAll() {
-  //debug('now');
-%      for my $dd (0..$a{Dropdowns}-1) {
-  ms_Prep('<% $dd %>');
-%      }
-  //debug('ms_PrepAll done '+ms_lists);
-}
-ms_PrepAll();
-</script>
-% }
-
-% }
+% } #---------- end of dropdowns, now common code ----------
 
 <input type=submit name=submit value="Go">
 </form>
@@ -281,6 +225,14 @@ Debug log:
 </pre>
 % }
 
+<script type="text/javascript">
+function debug (m) {
+% if ($debug) {
+  var node= document.getElementById('debug_log');
+  node.innerHTML += "\n" + m + "\n";
+% }
+}
+</script>
 
 <%init>
 use CommodsWeb;