1 (function($){$(function(){
3 var interestingReferences = $("#interesting-references").text();
4 if (interestingReferences) {
5 interestingReferences = $.parseJSON(interestingReferences);
7 if (interestingReferences) {
8 $("#settings-references").show();
13 var map_enabled = false;
14 var marker = L.marker([0,0]);
17 function enable_map() {
18 if (map_enabled) return;
20 map = L.map('reference-map').setView([0, 0], 11);
21 L.tileLayer('https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png?lang=pl', {
22 attribution: 'Map data © <a href="http://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
27 function disable_map() {
28 $("#reference-map").hide('slow');
32 $("#reference-close").on("click", function() {
33 $("#reference-box").hide();
36 $('a.reference').each(function() {
38 uri = $this.attr('data-uri');
39 if (interestingReferences.hasOwnProperty(uri)) {
40 $this.addClass('interesting');
41 ref = interestingReferences[uri];
43 $this.attr('href', ref.wikipedia_link);
44 $this.attr('target', '_blank');
49 $('a.reference.interesting').on('click', function(event) {
50 event.preventDefault();
52 $("#reference-box").show();
55 uri = $this.attr('data-uri');
56 ref = interestingReferences[uri];
61 marker.setLatLng(ref.location);
62 //marker.setContent(ref.label);
63 marker.bindTooltip(ref.label).openTooltip();
65 map.panTo(ref.location, {
72 map.removeLayer(marker);
76 $("#reference-images img").remove();
78 $.each(ref.images, function(i, e) {
79 $i = $("<a target='_blank'><img></a>");
80 $i.attr('href', e.page);
81 $('img', $i).attr('src', e.url);
82 $("#reference-images").append($i);
86 $("#reference-link").text(ref.label);
87 $("#reference-link").attr('href', ref.wikipedia_link);