]> git.mxchange.org Git - friendica-addons.git/blob - openstreetmap/openstreetmap.js
Update t() calls
[friendica-addons.git] / openstreetmap / openstreetmap.js
1 var toolserver = 'http://toolserver.org/~kolossos/openlayers/kml-on-ol.php';\r
2 var startTag = '<iframe class="osmFrame" style="width: 100%; height: 350px; clear: both;" src="'+ toolserver + '?lang=de&amp;uselang=de&amp;params=';\r
3 var endTag = '"></iframe>';\r
4 \r
5 // @TODO document.ready() does not work for ajax loaded content\r
6 jQuery(document).ready(function($) {\r
7         $('.wall-item-content-wrapper').each(function(index) {\r
8                 var link = $(this).find('.wall-item-location .OSMMapLink');\r
9                 link.toggle(addIframe, removeIframe);\r
10         });\r
11 });\r
12 \r
13 function addIframe(ev) {\r
14         var coordinate = $(ev.target).attr('title');\r
15         var newTag = startTag + convertCoordinateString(coordinate) + endTag;\r
16         $(ev.target).parents('.wall-item-content-wrapper').append(newTag);\r
17 }\r
18 \r
19 function removeIframe(ev) {\r
20         $(ev.target).parents('.wall-item-content-wrapper').find('iframe').remove();\r
21 }\r
22 \r
23 function convertCoordinateString(coordinate) {\r
24         var locstring = coordinate.split(' ');\r
25         var northSouth;\r
26         var westEast;\r
27 \r
28         if (locstring[0] < 0) {\r
29                 northSouth = '_S_';\r
30         }else{\r
31                 northSouth = '_N_';\r
32         }\r
33         if (locstring[1] < 0) {\r
34                 westEast = '_W';\r
35         }else{\r
36                 westEast = '_E';\r
37         }\r
38         return Math.abs(locstring[0]) + northSouth + Math.abs(locstring[1]) + westEast;\r
39 }\r
40 \r