@vars= ({ Name => 'Ocean',
Before => 'Ocean: ',
CmpCanon => sub { ucfirst lc $_[0] },
- Values => [ qw(Midnight Ice) ]
+ Values => [ ocean_list() ]
}, { Name => 'Dropdowns',
Before => 'Interface: ',
CmpCanon => sub { !!$_[0] },
$qf{$n}= $value;
}
}
- my $uri= URI->new($self_url);
+ my $uri= URI->new($m->current_comp()->name());
$uri->query_form(%qf);
print '<a href="', $uri->path_query(), '">';
$after= '</a>';
print '<p>';
}
-db_setocean($a{'ocean'});
+die "unknown ocean $a{Ocean} ?"
+ unless grep { $_ eq $a{Ocean} } ocean_list();
+
+db_setocean($a{Ocean});
db_connect();
</%perl>
<form action="/ucgi/~clareb/mason/something" method="get">
% if (!$a{Dropdowns}) {
-Enter route (islands, or archipelagoes, separated by commas;
- abbreviations are OK):<br>
+Enter route (islands, or archipelagoes, separated by |s or commas;
+ abbreviations are OK):<br/>
<script type="text/javascript">
+textRoute_uri= "routetextstring?format=json"
+ + "&ocean=<% uri_escape($a{Ocean}) %>";
+
textRoute_timeout=false;
textRoute_request=false;
textRoute_done='';
textRoute_Request();
}
function textRoute_Request(){
- if (textRoute_request || textRoute_needed==textRoute_done) {
- alert('unneeded');
- return;
- }
+ if (textRoute_request || textRoute_needed==textRoute_done) return;
textRoute_done= textRoute_needed;
- alert(String.concat('needed! ',textRoute_done));
+ textRoute_request= new XMLHttpRequest();
+ uri= textRoute_uri+'&string='+encodeURIComponent(textRoute_needed);
+ textRoute_request.open('GET', uri);
+ textRoute_request.onreadystatechange= textRoute_Ready;
+ textRoute_request.send(null);
+}
+function textRoute_Ready() {
+ if (textRoute_request.readyState != 4) return;
+ if (textRoute_request.status == 200) {
+ response= textRoute_request.responseText;
+ //alert('got [[ '+response+' ]]');
+ eval('results='+response);
+ toedit= document.getElementsByName('routeresults').item(0);
+ toedit.innerHTML= results['show'];
+ }
+ textRoute_request= false;
+ textRoute_Request();
}
</script>
<input type="text" name="routestring" size=80
onchange="textRoute_element= event.currentTarget; textRoute_Needed();"
onkeydown="textRoute_element= event.currentTarget; textRoute_Later();"><br>
-<div name="results"></div></br>
+<div name="routeresults"> </div><br/>
% } else {
sprintf('<option value="%s">%s</option>',
map { encode_entities($_) } @$row);
}
+
+$sth=$dbh->prepare("SELECT DISTINCT archipelago FROM islands
+ ORDER BY archipelago;");
+$sth->execute();
+my $archlistdata='';
+
+while ($row=$sth->fetchrow_arrayref) {
+ $archlistdata.=
+ sprintf('<option value="%s">%s</option>',
+ map { encode_entities($_) } (@$row, @$row));
+}
</%perl>
+<script type="text/javascript">
+function setarch(dd) {
+ alert('setarch '+dd);
+}
+function setisland(dd) {
+ alert('setisland '+dd);
+}
+</script>
+
<table>
+
<tr>
% for my $dd (0..$a{Dropdowns}-1) {
-<td><select name="islandid<% $dd %>">
+<td><select name="archipelago<% $dd %>" onchange="setarch(<% $dd %>)">
+<option name="none">Whole ocean</option>
+<% $archlistdata %></select></td>
+% }
+</tr>
+
+<tr>
+% for my $dd (0..$a{Dropdowns}-1) {
+<td><select name="islandid<% $dd %>" onchange="setisland(<% $dd %>)">
<option name="none">Select island...</option>
<% $islandlistdata %></select></td>
% }
-% }
</tr>
+
</table>
+% }
<input type=submit name=submit value="Go">
</form>
<%init>
use CommodsWeb;
use HTML::Entities;
+use URI::Escape;
</%init>