X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/9172695f7f94bb60dd01455a922e22d181eb284e..c26b60c4c6ec77e903a25adcc8a2ddbd73aa2ebf:/app/assets/javascripts/application.js?ds=sidebyside diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 84305a961..fc426e883 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -114,6 +114,10 @@ function updatelinks(loc, zoom, layers, bounds, object) { } } +function minZoomAlert() { + alert(I18n.t("javascripts.site." + name + "_zoom_alert")); return false; +} + function getShortUrl(map) { return (window.location.hostname.match(/^www\.openstreetmap\.org/i) ? 'http://osm.org/go/' : '/go/') + @@ -123,19 +127,17 @@ function getShortUrl(map) { function getUrl(map) { var center = map.getCenter(), zoom = map.getZoom(); + return (window.location.hostname.match(/^www\.openstreetmap\.org/i) ? 'http://openstreetmap.org/?' : '/?') + querystring.stringify({ lat: center.lat, lon: center.lng, - zoom: zoom + zoom: zoom, + layers: map.getLayersCode() }); } -function minZoomAlert() { - alert(I18n.t("javascripts.site." + name + "_zoom_alert")); return false; -} - // Called to create a short code for the short link. function makeShortCode(map) { var zoom = map.getZoom(), @@ -174,6 +176,12 @@ function makeShortCode(map) { return str; } +// 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('|'); +} + /* * Forms which have been cached by rails may have the wrong * authenticity token, so patch up any forms with the correct