Add coordinate toggling to html documents

main
parent 2929f226c9
commit 238cd08c8f
  1. 16
      wiki-map.pl

@ -162,9 +162,9 @@ foreach my $page (values %{$location_query_results->{query}{pages}})
my ($nw, $sw) = ($1, $2); my ($nw, $sw) = ($1, $2);
$location->make_tile_at($nw, $sw); $location->make_tile_at($nw, $sw);
my $region_name = $parsed_template->{positional_params}[1]; my $region_name = $parsed_template->{positional_params}[1];
$region_grids{$region_name}->add_region($location);
if($regiondir) if($regiondir)
{ {
$region_grids{$region_name}->add_region($location);
my $region_name = $parsed_template->{positional_params}[1]; my $region_name = $parsed_template->{positional_params}[1];
$region_grids{$region_name}->add_region($location); $region_grids{$region_name}->add_region($location);
@ -314,6 +314,20 @@ sub wrap_in_html($grid)
} }
</script> </script>
EOS EOS
if($show_coords)
{
$html_builder .= <<EOS;
<script>
function toggleCoords(show) {
for (var elem of document.getElementsByClassName('coords')) {
elem.style.visibility = show ? 'visible' : 'hidden';
}
}
</script>
<label for="show-coords-checkbox">Show coordinates</label>
<input type="checkbox" checked id="show-coords-checkbox" onclick="toggleCoords(event.srcElement.checked)" />
EOS
}
$html_builder .= "\n" . $grid->render; $html_builder .= "\n" . $grid->render;
$html_builder .= "\n</body>\n</html>"; $html_builder .= "\n</body>\n</html>";
return $html_builder; return $html_builder;

Loading…
Cancel
Save