1 (function($){$(function(){
3 var interestingReferences = $("#interesting-references").text();
4 if (interestingReferences) {
5 interestingReferences = $.parseJSON(interestingReferences);
7 if (Object.keys(interestingReferences).length) {
8 $("#settings-references").css('display', 'block');
13 var map_enabled = false;
14 var marker = L.marker([0,0]);
17 function enable_map() {
18 $("#reference-map").show('slow');
20 if (map_enabled) return;
22 map = L.map('reference-map').setView([0, 0], 11);
23 L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=a8a97f0ae5134403ac38c1a075b03e15', {
24 attribution: 'Maps © <a href="http://www.thunderforest.com">Thunderforest</a>, Data © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>'
29 function disable_map() {
30 $("#reference-map").hide('slow');
34 $("#reference-close").on("click", function(event) {
35 event.preventDefault();
36 $("#reference-box").hide();
39 $('a.reference').each(function() {
41 uri = $this.attr('data-uri');
42 if (interestingReferences.hasOwnProperty(uri)) {
43 $this.addClass('interesting');
44 ref = interestingReferences[uri];
46 $this.attr('href', ref.wikipedia_link);
47 $this.attr('target', '_blank');
52 $('a.reference.interesting').on('click', function(event) {
53 event.preventDefault();
55 $("#reference-box").show();
58 uri = $this.attr('data-uri');
59 ref = interestingReferences[uri];
64 marker.setLatLng(ref.location);
65 //marker.setContent(ref.label);
66 marker.bindTooltip(ref.label).openTooltip();
68 map.panTo(ref.location, {
75 map.removeLayer(marker);
79 $("#reference-images a").remove();
81 $.each(ref.images, function(i, e) {
82 $i = $("<a target='_blank'><img></a>");
83 $i.attr('href', e.page);
84 $('img', $i).attr('src', e.url);
85 $("#reference-images").append($i);
89 $("#reference-link").text(ref.label);
90 $("#reference-link").attr('href', ref.wikipedia_link);