- var name = link.id.replace(/anchor$/, "");
-
- $(link).off("click.minzoom");
-
- if (zoom >= minzoom) {
- $(link).attr("title", I18n.t("javascripts.site." + name + "_tooltip"));
- $(link).removeClass("disabled");
- } else {
- $(link).on("click.minzoom", function () { alert(I18n.t("javascripts.site." + name + "_zoom_alert")); return false; });
- $(link).attr("title", I18n.t("javascripts.site." + name + "_disabled_tooltip"));
- $(link).addClass("disabled");
- }
- }
-
- 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 "";
- }
-}
-
-/*
- * Called to get the arguments from a URL as a hash.
- */
-function getArgs(url) {
- var args = {};
- var querystart = url.indexOf("?");
-
- if (querystart >= 0) {
- var querystring = url.substring(querystart + 1);
- var queryitems = querystring.split("&");
-
- for (var i = 0; i < queryitems.length; i++) {
- if (match = queryitems[i].match(/^(.*)=(.*)$/)) {
- args[unescape(match[1])] = unescape(match[2]);
- } else {
- args[unescape(queryitems[i])] = null;
- }
- }
- }
-
- return args;
-}
-
-/*
- * Called to set the arguments on a URL from the given hash.
- */
-function setArgs(url, args) {
- var queryitems = [];
-
- for (arg in args) {
- if (args[arg] == null) {
- queryitems.push(escape(arg));