Update with hash permalinks
authorJohn Firebaugh <john.firebaugh@gmail.com>
Tue, 6 Aug 2013 18:20:05 +0000 (11:20 -0700)
committerJohn Firebaugh <john.firebaugh@gmail.com>
Mon, 12 Aug 2013 20:34:45 +0000 (13:34 -0700)
app/assets/javascripts/welcome.js

index 5773bfd6dbc6260c935561f93e072816f25276f6..60648383adc10efa3979950848b5ef47c834be2c 100644 (file)
@@ -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() {