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 console.log('check ' + uri);
40 if (interestingReferences.hasOwnProperty(uri)) {
41 $this.addClass('interesting');
42 ref = interestingReferences[uri];
44 $this.attr('href', ref.wikipedia_link);
45 $this.attr('target', '_blank');
50 $('a.reference.interesting').on('click', function(event) {
51 event.preventDefault();
53 $("#reference-box").show();
56 uri = $this.attr('data-uri');
57 ref = interestingReferences[uri];
62 marker.setLatLng(ref.location);
63 //marker.setContent(ref.label);
64 marker.bindTooltip(ref.label).openTooltip();
66 map.panTo(ref.location, {
73 map.removeLayer(marker);
77 $("#reference-images img").remove();
79 $.each(ref.images, function(i, e) {
80 $i = $("<a target='_blank'><img></a>");
81 $i.attr('href', e.page);
82 $('img', $i).attr('src', e.url);
83 $("#reference-images").append($i);
87 $("#reference-link").text(ref.label);
88 $("#reference-link").attr('href', ref.wikipedia_link);