Refactor updatelinks to avoid exceptions in updateLocation
This commit is contained in:
parent
3cf3d888b2
commit
824a474d93
3 changed files with 8 additions and 8 deletions
|
@ -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 || args[object.type]) {
|
||||
this.href = setArgs(prefix + "/go/" + code, args);
|
||||
} else {
|
||||
this.href = prefix + "/go/" + code;
|
||||
|
|
|
@ -71,7 +71,7 @@ $(document).ready(function () {
|
|||
$("#object_larger_map").show();
|
||||
$("#object_edit").show();
|
||||
|
||||
updatelinks(centre.lon, centre.lat, 16, null, extent.left, extent.bottom, extent.right, extent.top, params.type, params.id);
|
||||
updatelinks(centre.lon, centre.lat, 16, null, extent.left, extent.bottom, extent.right, extent.top, object);
|
||||
} else {
|
||||
$("#small_map").hide();
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ $(document).ready(function () {
|
|||
var extents = unproj(map.getExtent());
|
||||
var expiry = new Date();
|
||||
|
||||
updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top, params.object.type, params.object.id);
|
||||
updatelinks(lonlat.lon, lonlat.lat, zoom, layers, extents.left, extents.bottom, extents.right, extents.top, params.object);
|
||||
|
||||
expiry.setYear(expiry.getFullYear() + 10);
|
||||
$.cookie("_osm_location", [lonlat.lon, lonlat.lat, zoom, layers].join("|"), {expires: expiry});
|
||||
|
|
Loading…
Add table
Reference in a new issue