2017-11-17 03:26:17 +04:00
|
|
|
(function(d) {
|
|
|
|
let f = d.querySelector('footer');
|
|
|
|
f.insertAdjacentHTML(
|
|
|
|
'afterbegin',
|
|
|
|
'<p><a href="#help" title="Help" accesskey="?">?</a></p>')
|
2017-12-25 19:43:06 +04:00
|
|
|
f.querySelector('[href="#help"]').addEventListener('click', e => {
|
2017-11-27 00:31:48 +04:00
|
|
|
if (d.getElementById('help') == null) {
|
2017-11-17 03:26:17 +04:00
|
|
|
f.insertAdjacentHTML(
|
|
|
|
'beforebegin',
|
|
|
|
'<div id="help"><h2>Key bindings</h2>' +
|
|
|
|
[].map.call(
|
2017-11-27 00:31:48 +04:00
|
|
|
d.querySelectorAll('[accesskey]'),
|
2017-11-17 03:26:17 +04:00
|
|
|
e => e.accessKeyLabel + ": " + (e.title || e.innerText)).join('<br/>') +
|
|
|
|
'</div>');
|
|
|
|
}
|
|
|
|
return true;
|
2017-12-25 19:43:06 +04:00
|
|
|
});
|
2018-02-11 18:32:15 +04:00
|
|
|
var map;
|
|
|
|
function resize_map() {
|
|
|
|
var me = d.getElementById('map');
|
|
|
|
if (me) {
|
|
|
|
me.style.height = 4 * me.clientWidth / 5 + "px";
|
|
|
|
}
|
|
|
|
if (map) {
|
|
|
|
map.invalidateSize(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
window.addEventListener('resize', resize_map);
|
2017-12-25 19:43:06 +04:00
|
|
|
let i = d.querySelector('.details .item');
|
2017-12-12 02:35:23 +04:00
|
|
|
if (i) {
|
2018-02-11 18:32:15 +04:00
|
|
|
i.addEventListener('click', e => {
|
|
|
|
i.classList.toggle('zoom');
|
|
|
|
resize_map();
|
|
|
|
});
|
2017-12-12 02:35:23 +04:00
|
|
|
}
|
2018-02-07 23:56:23 +04:00
|
|
|
function prepare_map(cb) {
|
|
|
|
let h = d.querySelector('head');
|
2018-07-16 00:46:50 +04:00
|
|
|
var csslink = d.createElement('link');
|
|
|
|
csslink.rel = 'stylesheet';
|
2019-04-26 02:33:59 +04:00
|
|
|
csslink.href = '/static/l140/leaflet.css';
|
2018-07-16 00:46:50 +04:00
|
|
|
h.append(csslink);
|
2018-02-07 23:56:23 +04:00
|
|
|
let m = d.querySelector('.meta') || d.querySelector('main');
|
|
|
|
m.insertAdjacentHTML('beforeend', '<div id="map"></div>');
|
|
|
|
var slink = d.createElement('script');
|
|
|
|
slink.type = 'text/javascript';
|
2019-04-26 02:33:59 +04:00
|
|
|
slink.src = '/static/l140/leaflet.js';
|
2018-02-07 23:56:23 +04:00
|
|
|
slink.async = 'async';
|
2018-02-11 16:32:23 +04:00
|
|
|
slink.onload = () => {
|
2018-02-11 18:32:15 +04:00
|
|
|
map = L.map('map', {'scrollWheelZoom': false, 'trackResize': false});
|
2018-02-11 16:32:23 +04:00
|
|
|
L.tileLayer('//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
|
|
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
|
|
|
}).addTo(map);
|
2018-02-11 18:32:15 +04:00
|
|
|
resize_map();
|
2018-02-11 16:32:23 +04:00
|
|
|
cb(map);
|
|
|
|
}
|
2018-02-07 23:56:23 +04:00
|
|
|
h.append(slink);
|
|
|
|
}
|
2018-02-05 02:42:15 +04:00
|
|
|
let details = d.querySelector('.details');
|
|
|
|
let pos = details && details.dataset.position
|
|
|
|
if (pos) {
|
2018-02-11 16:32:23 +04:00
|
|
|
prepare_map((map) => {
|
2018-02-11 18:32:15 +04:00
|
|
|
let p = JSON.parse(pos);
|
|
|
|
map.setView(p, 16);
|
|
|
|
L.marker(p).addTo(map);
|
2018-02-11 16:32:23 +04:00
|
|
|
})
|
2018-02-07 23:56:23 +04:00
|
|
|
}
|
|
|
|
let group = d.querySelector('.group');
|
|
|
|
let poss = (details && details.dataset.positions) || (group && group.dataset.positions);
|
|
|
|
if (poss) {
|
2018-02-11 16:32:23 +04:00
|
|
|
prepare_map((map) => {
|
2018-07-18 23:20:38 +04:00
|
|
|
let h = d.querySelector('head');
|
|
|
|
h.insertAdjacentHTML(
|
|
|
|
'beforeend',
|
2019-04-26 02:33:59 +04:00
|
|
|
'<link rel="stylesheet" href="/static/lm141/lmc.css">' +
|
|
|
|
'<link rel="stylesheet" href="/static/lm141/lmc-default.css">'
|
2018-07-18 23:20:38 +04:00
|
|
|
)
|
|
|
|
var slink2 = d.createElement('script');
|
|
|
|
slink2.type = 'text/javascript';
|
2019-04-26 02:33:59 +04:00
|
|
|
slink2.src = '/static/lm141/lmc.js';
|
2018-07-18 23:20:38 +04:00
|
|
|
h.append(slink2);
|
|
|
|
slink2.onload = () => {
|
|
|
|
let pos = JSON.parse(poss);
|
2018-08-12 13:29:17 +04:00
|
|
|
var markers = L.markerClusterGroup({maxClusterRadius: 35});
|
2018-07-18 23:20:38 +04:00
|
|
|
map.fitBounds(L.polyline(pos).getBounds());
|
|
|
|
pos.forEach(p => {
|
2018-07-19 23:17:00 +04:00
|
|
|
let n = p.pop();
|
|
|
|
let m = L.marker(p, { title: n });
|
|
|
|
m.bindPopup(`<a href="/img/${n}"><img src="/img/${n}-s.jpg"></a>`);
|
2018-07-18 23:20:38 +04:00
|
|
|
markers.addLayer(m);
|
|
|
|
});
|
|
|
|
map.addLayer(markers);
|
|
|
|
};
|
2018-02-11 16:32:23 +04:00
|
|
|
})
|
2018-02-05 02:42:15 +04:00
|
|
|
}
|
2017-11-17 03:26:17 +04:00
|
|
|
})(document)
|