From a4f37de7e9d3ff9416995375b3f2a1e33762ca72 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 6 Aug 2013 11:20:05 -0700 Subject: [PATCH] Update with hash permalinks --- app/assets/javascripts/welcome.js | 44 +++++++++++-------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/app/assets/javascripts/welcome.js b/app/assets/javascripts/welcome.js index 5773bfd6d..60648383a 100644 --- a/app/assets/javascripts/welcome.js +++ b/app/assets/javascripts/welcome.js @@ -2,39 +2,27 @@ $(document).ready(function() { var params = OSM.params(); if (params.lat && params.lon) { - $('.edit-located').show(); - - $.ajax({ - url: "http://nominatim.openstreetmap.org/reverse", - data: { - lat: params.lat, - lon: params.lon, - zoom: 10 - }, - success: function(xml) { - var result = $(xml).find('result'); - if (result.length) { - $('.edit-located').hide(); - $('.edit-geocoded').show(); - $('.edit-geocoded-location').text(result.text()); - } - } - }); + params.lat = parseFloat(params.lat); + params.lon = parseFloat(params.lon); + params.zoom = params.zoom || 17; - params = { - lat: params.lat, - lon: params.lon, - zoom: params.zoom || 17, - editor: params.editor - }; + var url = '/edit'; - $('.start-mapping').attr('href', '/edit?' + $.param(params)); + if (params.editor) { + url += '?editor=' + params.editor; + } - } else if (navigator.geolocation) { - $('.edit-geolocated').show(); + url += OSM.formatHash(params); + $('.start-mapping').attr('href', url); + + } else if (navigator.geolocation) { function geoSuccess(position) { - window.location = '/edit?zoom=17&lat=' + position.coords.latitude + '&lon=' + position.coords.longitude; + window.location = '/edit' + OSM.formatHash({ + zoom: 17, + lat: position.coords.latitude, + lon: position.coords.longitude + }); } function geoError() { -- 2.39.5