Separate event script from event data

This commit is contained in:
Saivann 2015-05-01 14:18:03 -04:00
parent 4a89cc4974
commit 262b550c18
4 changed files with 21 additions and 10 deletions

View file

@ -3,7 +3,7 @@ layout: null
---
var zoom=2;
var minzoom=1;
if(/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))var zoom=minzoom=0;
if(isMobile())var zoom=minzoom=0;
var map = L.map('eventmap',{ 'zoom': zoom, 'minZoom': minzoom, 'center': [20.00, 10.00]});
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Data &copy; by <a href="http://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>.',
@ -11,12 +11,8 @@ L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
}).addTo(map);
var markers = new L.MarkerClusterGroup({showCoverageOnHover: false, maxClusterRadius: 40});
{% filter_for p in site.conferences sort_by:date %}{% if p.geoloc %}
L.marker([{{ p.geoloc }}]).bindPopup('<b><a href="{{ p.link | htmlescape }}">{{ p.title | htmlescape }}</a></b><br>{{ p.date }}<br>{{ p.venue | htmlescape }}<br>{{ p.address | htmlescape }}<br>{{ p.city | htmlescape }}, {{ p.country | htmlescape }}').addTo(markers);
{% endif %}{% endfilter_for %}
{% filter_for p in site.meetups sort_by:date %}{% if p.geoloc %}
L.marker([{{ p.geoloc }}]).bindPopup('<b><a href="{{ p.link | htmlescape }}">{{ p.title | htmlescape }}</a></b><br>{{ p.date }}<br>{{ p.venue | htmlescape }}<br>{{ p.address | htmlescape }}<br>{{ p.city | htmlescape }}, {{ p.country | htmlescape }}').addTo(markers);
{% endif %}{% endfilter_for %}
for (var i=0, nds=document.getElementById('eventdata').getElementsByTagName('DIV'), n=nds.length; i < n; i++) {
L.marker([parseFloat(nds[i].getAttribute('data-lat')), parseFloat(nds[i].getAttribute('data-lon'))]).bindPopup(nds[i].innerHTML).addTo(markers);
}
map.addLayer(markers);