]> git.openstreetmap.org Git - rails.git/commitdiff
Move cookieContent to OSM.locationCookie
authorTom Hughes <tom@compton.nu>
Fri, 28 Feb 2014 00:10:55 +0000 (00:10 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 28 Feb 2014 00:10:55 +0000 (00:10 +0000)
app/assets/javascripts/application.js
app/assets/javascripts/index.js
app/assets/javascripts/osm.js.erb

index 75b48ac8715362aaa4fdb8dfd48735f4deeb4386..6ac398fc591687410467ee4cf15c7be9f3bd5c3a 100644 (file)
@@ -97,12 +97,6 @@ function updateLinks(loc, zoom, layers, object) {
       I18n.t('javascripts.site.edit_disabled_tooltip') : '');
 }
 
       I18n.t('javascripts.site.edit_disabled_tooltip') : '');
 }
 
-// generate a cookie-safe string of map state
-function cookieContent(map) {
-  var center = map.getCenter().wrap();
-  return [center.lng, center.lat, map.getZoom(), map.getLayersCode()].join('|');
-}
-
 function escapeHTML(string) {
   var htmlEscapes = {
     '&': '&amp;',
 function escapeHTML(string) {
   var htmlEscapes = {
     '&': '&amp;',
index 4a9abc4dc0f78fe5fbb602f3d938a4cf2ff9b737..dc3c932773066ce56a518a9b1c921659cf5ee7e8 100644 (file)
@@ -151,7 +151,7 @@ $(document).ready(function () {
       map._object);
 
     $.removeCookie("_osm_location");
       map._object);
 
     $.removeCookie("_osm_location");
-    $.cookie("_osm_location", cookieContent(map), { expires: expiry, path: "/" });
+    $.cookie("_osm_location", OSM.locationCookie(map), { expires: expiry, path: "/" });
   });
 
   if ($.cookie('_osm_welcome') == 'hide') {
   });
 
   if ($.cookie('_osm_welcome') == 'hide') {
index 382e32bdfde5d2285b065a685378bb796514eeb5..bd65182a7d7c9bf393636fb85623c7d6002d464a 100644 (file)
@@ -165,7 +165,12 @@ OSM = {
     return hash;
   },
 
     return hash;
   },
 
-  zoomPrecision: function (zoom) {
+  zoomPrecision: function(zoom) {
     return Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
     return Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
+  },
+
+  locationCookie: function(map) {
+    var center = map.getCenter().wrap();
+    return [center.lng, center.lat, map.getZoom(), map.getLayersCode()].join('|');
   }
 };
   }
 };