-
- link.href = setArgs(link.href, args);
- });
-
- $("#shortlinkanchor").each(function () {
- var args = getArgs(this.href);
- var code = makeShortCode(lat, lon, zoom);
- var prefix = shortlinkPrefix();
-
- // Add ?{node,way,relation}=id to the arguments
- if (objtype && objid) {
- args[objtype] = objid;
- }
-
- // This is a hack to omit the default mapnik layer from the shortlink.
- if (layers && layers != "M") {
- args.layers = layers;
- }
- else {
- delete args.layers;
- }
-
- // Here we're assuming that all parameters but ?layers= and
- // ?{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]) {
- this.href = setArgs(prefix + "/go/" + code, args);
- } else {
- this.href = prefix + "/go/" + code;
- }
- });
-}
-
-/*
- * Get the URL prefix to use for a short link
- */
-function shortlinkPrefix() {
- if (window.location.hostname.match(/^www\.openstreetmap\.org/i)) {
- return "http://osm.org";
- } else {
- return "";