From 238cd08c8f1c76edd85f23fd7467b15fee3868ba Mon Sep 17 00:00:00 2001 From: Daniel Asher Resnick Date: Tue, 18 Jul 2023 19:36:19 -0500 Subject: [PATCH] Add coordinate toggling to html documents --- wiki-map.pl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/wiki-map.pl b/wiki-map.pl index c6f2c03..be7def4 100644 --- a/wiki-map.pl +++ b/wiki-map.pl @@ -162,9 +162,9 @@ foreach my $page (values %{$location_query_results->{query}{pages}}) my ($nw, $sw) = ($1, $2); $location->make_tile_at($nw, $sw); my $region_name = $parsed_template->{positional_params}[1]; - $region_grids{$region_name}->add_region($location); if($regiondir) { + $region_grids{$region_name}->add_region($location); my $region_name = $parsed_template->{positional_params}[1]; $region_grids{$region_name}->add_region($location); @@ -314,6 +314,20 @@ sub wrap_in_html($grid) } EOS + if($show_coords) + { + $html_builder .= < + function toggleCoords(show) { + for (var elem of document.getElementsByClassName('coords')) { + elem.style.visibility = show ? 'visible' : 'hidden'; + } + } + + + +EOS + } $html_builder .= "\n" . $grid->render; $html_builder .= "\n\n"; return $html_builder;