|
|
@ -3,6 +3,7 @@ use rlib '.'; |
|
|
|
|
|
|
|
|
|
|
|
use HexGrid; |
|
|
|
use HexGrid; |
|
|
|
use HexGrid::Pin; |
|
|
|
use HexGrid::Pin; |
|
|
|
|
|
|
|
use HexGrid::Dynamic; |
|
|
|
|
|
|
|
|
|
|
|
use Carp; |
|
|
|
use Carp; |
|
|
|
use Data::Dumper; |
|
|
|
use Data::Dumper; |
|
|
@ -31,38 +32,6 @@ while (my $line = <$test_fh>) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# say $grid->render; |
|
|
|
say $grid->render; |
|
|
|
say wrap_in_html($grid); |
|
|
|
# say HexGrid::Dynamic::render_html($grid->render, {}); |
|
|
|
close $test_fh; |
|
|
|
close $test_fh; |
|
|
|
|
|
|
|
|
|
|
|
sub wrap_in_html($grid) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
my $html_builder = "<!DOCTYPE html>"; |
|
|
|
|
|
|
|
$html_builder .= "\n<html>\n<body>"; |
|
|
|
|
|
|
|
$html_builder .= "\n" . <<EOS; |
|
|
|
|
|
|
|
<script> |
|
|
|
|
|
|
|
function clickPin(pinId, containerId) { |
|
|
|
|
|
|
|
let popup = document.getElementById(pinId + '-popup'); |
|
|
|
|
|
|
|
popup.style.visibility = popup.style.visibility == 'visible' ? 'hidden' : 'visible'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
EOS |
|
|
|
|
|
|
|
if(1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$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</body>\n</html>"; |
|
|
|
|
|
|
|
return $html_builder; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|