]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/application.js
Refactor notes code to work with recent site changes
[rails.git] / app / assets / javascripts / application.js
index 785862ccc47391473dced0ddc6fa47c5e82a9a56..c52c072a754fa941a33b61b920aebe96e7b3ffe0 100644 (file)
@@ -25,7 +25,7 @@ function zoomPrecision(zoom) {
  * Called as the user scrolls/zooms around to aniplate hrefs of the
  * view tab and various other links
  */
-function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,objid) {
+function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,object) {
   var toPrecision = zoomPrecision(zoom);
   var node;
 
@@ -54,8 +54,8 @@ function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,obj
       args.layers = layers;
     }
 
-    if (objtype && $(link).hasClass("object")) {
-      args[objtype] = objid;
+    if (object && $(link).hasClass("object")) {
+      args[object.type] = object.id;
     }
 
     var minzoom = $(link).data("minzoom");
@@ -83,8 +83,8 @@ function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,obj
     var prefix = shortlinkPrefix();
 
     // Add ?{node,way,relation}=id to the arguments
-    if (objtype && objid) {
-      args[objtype] = objid;
+    if (object) {
+      args[object.type] = object.id;
     }
 
     // This is a hack to omit the default mapnik layer from the shortlink.
@@ -99,7 +99,7 @@ function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,obj
     // ?{node,way,relation}= can be safely omitted from the shortlink
     // which encodes lat/lon/zoom. If new URL parameters are added to
     // the main slippy map this needs to be changed.
-    if (args.layers || args[objtype]) {
+    if (args.layers || object) {
       this.href = setArgs(prefix + "/go/" + code, args);
     } else {
       this.href = prefix + "/go/" + code;