2020-06-12 19:23:11 +02:00
|
|
|
<?php
|
|
|
|
$cssFiles = [
|
|
|
|
'css/maps.css'
|
|
|
|
];
|
|
|
|
?>
|
2020-05-31 20:45:57 +02:00
|
|
|
<?php require ROOT . '/views/templates/main_header.php'; ?>
|
|
|
|
<?php require ROOT . '/views/templates/header.php'; ?>
|
2020-06-01 20:39:23 +02:00
|
|
|
<div id="mapContainer">
|
2020-06-14 02:37:49 +02:00
|
|
|
<?php foreach ($maps as $map): ?>
|
2020-05-31 00:21:29 +02:00
|
|
|
<div class="mapItem">
|
|
|
|
<div class="title">
|
|
|
|
<p class="title"><?= $map['name'] ?></p>
|
|
|
|
</div>
|
2020-06-21 19:32:30 +02:00
|
|
|
<div class="imgContainer" data-bound-south-lat="<?= $map['bound_south_lat'] ?>" data-bound-west-lng="<?= $map['bound_west_lng'] ?>" data-bound-north-lat="<?= $map['bound_north_lat'] ?>" data-bound-east-lng="<?= $map['bound_east_lng'] ?>"></div>
|
2020-05-31 00:21:29 +02:00
|
|
|
<div class="inner">
|
|
|
|
<div class="info">
|
|
|
|
<p>
|
|
|
|
<?php /* Copyright (c) 2019 The Bootstrap Authors. License can be found in 'USED_SOFTWARE' in section 'Bootstrap Icons'. */ ?>
|
|
|
|
<svg class="inline" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
|
|
|
<path fill-rule="evenodd" d="M8 16s6-5.686 6-10A6 6 0 0 0 2 6c0 4.314 6 10 6 10zm0-7a3 3 0 1 0 0-6 3 3 0 0 0 0 6z" />
|
2020-06-21 17:36:08 +02:00
|
|
|
</svg><!--
|
|
|
|
--><?= $map['num_places'] ?> places
|
2020-05-31 00:21:29 +02:00
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<?php /* Copyright (c) 2019 The Bootstrap Authors. License can be found in 'USED_SOFTWARE' in section 'Bootstrap Icons'. */ ?>
|
|
|
|
<svg class="inline" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
|
|
|
<path fill-rule="evenodd" d="M12.5 2h-9V1h9v1zm-10 1.5v9h-1v-9h1zm11 9v-9h1v9h-1zM3.5 14h9v1h-9v-1z" />
|
|
|
|
<path fill-rule="evenodd" d="M14 3a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm0 1a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm0 11a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm0 1a2 2 0 1 0 0-4 2 2 0 0 0 0 4zM2 3a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm0 1a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm0 11a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm0 1a2 2 0 1 0 0-4 2 2 0 0 0 0 4z" />
|
2020-06-21 17:36:08 +02:00
|
|
|
</svg><!--
|
|
|
|
-->~ <?= $map['area'][0] ?> <?= $map['area'][1] ?><sup>2</sup>
|
2020-05-31 00:21:29 +02:00
|
|
|
</p>
|
2020-05-30 15:37:26 +02:00
|
|
|
</div>
|
2020-05-31 00:21:29 +02:00
|
|
|
<p class="small justify marginTop"><?= $map['description'] ?></p>
|
2020-05-30 15:37:26 +02:00
|
|
|
</div>
|
2020-06-10 20:20:36 +02:00
|
|
|
<?php if ($isAdmin): ?>
|
2020-06-10 23:17:13 +02:00
|
|
|
<div class="buttonContainer">
|
2020-06-14 02:37:49 +02:00
|
|
|
<a class="button fullWidth noRightRadius" href="/game/<?= $map['id']; ?>" title="Play map '<?= $map['name'] ?>'">Play this map</a>
|
|
|
|
<a class="button yellow fullWidth noLeftRadius noRightRadius" href="/admin/mapEditor/<?= $map['id']; ?>" title="Edit map '<?= $map['name'] ?>'">Edit</a>
|
|
|
|
<button class="button red fullWidth noLeftRadius deleteButton" data-map-id="<?= $map['id'] ?>" data-map-name="<?= htmlspecialchars($map['name']) ?>" title="Delete map '<?= $map['name'] ?>'">Delete</button>
|
2020-06-10 23:17:13 +02:00
|
|
|
</div>
|
|
|
|
<?php else: ?>
|
2020-06-14 02:37:49 +02:00
|
|
|
<a class="button fullWidth" href="/game/<?= $map['id']; ?>" title="Play map '<?= $map['name'] ?>'">Play this map</a>
|
2020-06-10 20:20:36 +02:00
|
|
|
<?php endif; ?>
|
2020-05-31 00:21:29 +02:00
|
|
|
</div>
|
|
|
|
<?php endforeach; ?>
|
2020-06-10 23:17:13 +02:00
|
|
|
<?php if ($isAdmin): ?>
|
|
|
|
<div class="mapItem new">
|
2020-06-14 02:37:49 +02:00
|
|
|
<a class="button green fullWidth" href="/admin/mapEditor" title="Add new map">
|
2020-06-10 23:17:13 +02:00
|
|
|
Add new map
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<?php else: ?>
|
|
|
|
<div class="mapItem"></div>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php if (count($maps) < 3): ?>
|
|
|
|
<?php for ($i = 0; $i < 3 - count($maps); ++$i): ?>
|
2020-05-31 00:21:29 +02:00
|
|
|
<div class="mapItem"></div>
|
|
|
|
<?php endfor; ?>
|
|
|
|
<?php endif; ?>
|
2020-05-30 15:37:26 +02:00
|
|
|
</div>
|
2020-06-21 22:20:30 +02:00
|
|
|
<?php require ROOT . '/views/templates/footer.php'; ?>
|
2020-06-21 19:32:30 +02:00
|
|
|
<script>
|
|
|
|
(function () {
|
|
|
|
const GOOGLE_MAPS_JS_API_KEY = '<?= $_ENV['GOOGLE_MAPS_JS_API_KEY'] ?>';
|
|
|
|
|
|
|
|
var imgContainers = document.getElementById('mapContainer').getElementsByClassName('imgContainer');
|
|
|
|
for (var i = 0; i < imgContainers.length; i++) {
|
|
|
|
var imgContainer = imgContainers[i];
|
|
|
|
|
|
|
|
var img = document.createElement('img');
|
|
|
|
|
|
|
|
img.src = 'https://maps.googleapis.com/maps/api/staticmap?size=350x175&' +
|
|
|
|
'scale=' + (window.devicePixelRatio >= 2 ? 2 : 1) + '&' +
|
|
|
|
'visible=' + imgContainer.dataset.boundSouthLat + ',' + imgContainer.dataset.boundWestLng + '|' +
|
|
|
|
imgContainer.dataset.boundNorthLat + ',' + imgContainer.dataset.boundEastLng +
|
|
|
|
'&key=' + GOOGLE_MAPS_JS_API_KEY;
|
|
|
|
img.alt = 'Map area';
|
|
|
|
|
|
|
|
imgContainer.appendChild(img);
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
</script>
|
2020-06-14 02:37:49 +02:00
|
|
|
<?php if ($isAdmin): ?>
|
|
|
|
<script>
|
2020-06-21 19:32:30 +02:00
|
|
|
(function () {
|
2020-06-14 02:37:49 +02:00
|
|
|
Maps = {
|
|
|
|
deleteMap: function(mapId, mapName) {
|
|
|
|
MapGuesser.showModalWithContent('Delete map', 'Are you sure you want to delete map \'' + mapName + '\'?', [{
|
|
|
|
type: 'button',
|
|
|
|
classNames: ['red'],
|
|
|
|
text: 'Delete',
|
|
|
|
onclick: function () {
|
|
|
|
document.getElementById('loading').style.visibility = 'visible';
|
|
|
|
|
|
|
|
MapGuesser.httpRequest('POST', '/admin/deleteMap/' + mapId, function () {
|
|
|
|
if (this.response.error) {
|
|
|
|
document.getElementById('loading').style.visibility = 'hidden';
|
|
|
|
|
|
|
|
//TODO: handle this error
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
window.location.reload();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var buttons = document.getElementById('mapContainer').getElementsByClassName('deleteButton');
|
2020-06-21 19:32:30 +02:00
|
|
|
for (var i = 0; i < buttons.length; i++) {
|
|
|
|
var button = buttons[i];
|
|
|
|
|
2020-06-14 02:37:49 +02:00
|
|
|
button.onclick = function() {
|
|
|
|
Maps.deleteMap(this.dataset.mapId, this.dataset.mapName);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
</script>
|
|
|
|
<?php endif; ?>
|
2020-05-31 20:45:57 +02:00
|
|
|
<?php require ROOT . '/views/templates/main_footer.php'; ?>
|