fix
[wolnelektury.git] / src / wolnelektury / static / js / book_text / references.js
index b75a4da..cdfc1f0 100644 (file)
     $('a.reference').each(function() {
         $this = $(this);
         uri = $this.attr('data-uri');
     $('a.reference').each(function() {
         $this = $(this);
         uri = $this.attr('data-uri');
+        if (uri == '') {
+            $this.remove();
+            return;
+        }
         if (interestingReferences.hasOwnProperty(uri)) {
             $this.addClass('interesting');
             ref = interestingReferences[uri];
         if (interestingReferences.hasOwnProperty(uri)) {
             $this.addClass('interesting');
             ref = interestingReferences[uri];
         if (ref.location) {
             enable_map();
 
         if (ref.location) {
             enable_map();
 
-            marker.setLatLng(ref.location);
+            let newLoc = [
+                ref.location[0],
+                ref.location[1] + Math.round(
+                    (map.getCenter().lng - ref.location[1]) / 360
+                ) * 360
+            ];
+
+            marker.setLatLng(newLoc);
             marker.bindTooltip(ref.label).openTooltip();
             map.addLayer(marker);
             marker.bindTooltip(ref.label).openTooltip();
             map.addLayer(marker);
-            map.panTo(ref.location, {
+
+            map.panTo(newLoc, {
                 animate: true,
                 duration: 1,
             });
                 animate: true,
                 duration: 1,
             });
 
         $("#reference-link").text(ref.label);
         $("#reference-link").attr('href', ref.wikipedia_link);
 
         $("#reference-link").text(ref.label);
         $("#reference-link").attr('href', ref.wikipedia_link);
+
+        _paq.push(['trackEvent', 'html', 'reference']);
     });
 })})(jQuery);
     });
 })})(jQuery);