<commit_before>
/*
 * 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) {
  var decimals = Math.pow(10, Math.floor(zoom/3));
  var node;

  lat = Math.round(lat * decimals) / decimals;
  lon = Math.round(lon * decimals) / decimals;

  node = $("permalinkanchor");
  if (node) {
    var args = getArgs(node.href);
    args["lat"] = lat;
    args["lon"] = lon;
    args["zoom"] = zoom;
    if (layers) {
      args["layers"] = layers;
    }
    if (objtype && objid) {
      args[objtype] = objid;
    }
    node.href = setArgs(node.href, args);
  }

  node = $("viewanchor");
  if (node) {
    var args = getArgs(node.href);
    args["lat"] = lat;
    args["lon"] = lon;
    args["zoom"] = zoom;
    if (layers) {
      args["layers"] = layers;
    }
    node.href = setArgs(node.href, args);
  }

  node = $("exportanchor");
  if (node) {
    var args = getArgs(node.href);
    args["lat"] = lat;
    args["lon"] = lon;
    args["zoom"] = zoom;
    if (layers) {
      args["layers"] = layers;
    }
    node.href = setArgs(node.href, args);
  }

  node = $("editanchor");
  if (node) {
    if (zoom >= 13) {
      var args = new Object();
      args.lat = lat;
      args.lon = lon;
      args.zoom = zoom;
      if (objtype && objid) {
        args[objtype] = objid;
      }
      node.href = setArgs("/edit", args);
      node.title = i18n("javascripts.site.edit_tooltip");
      node.removeClassName("disabled");
    } else {
      node.href = 'javascript:alert(i18n("javascripts.site.edit_zoom_alert"));';
      node.title = i18n("javascripts.site.edit_disabled_tooltip");
      node.addClassName("disabled");
    }
  }

  node = $("historyanchor");
  if (node) {
    if (zoom >= 11) {
      var args = new Object();
      //set bbox param from 'extents' object
      if (typeof minlon == "number" &&
	  typeof minlat == "number" &&
	  typeof maxlon == "number" &&
	  typeof maxlat == "number") {

        minlon = Math.round(minlon * decimals) / decimals;
        minlat = Math.round(minlat * decimals) / decimals;
        maxlon = Math.round(maxlon * decimals) / decimals;
        maxlat = Math.round(maxlat * decimals) / decimals;
        args.bbox = minlon + "," + minlat + "," + maxlon + "," + maxlat;
      }

      node.href = setArgs("/history", args);
      node.title = i18n("javascripts.site.history_tooltip");
      node.removeClassName("disabled");
    } else {
      node.href = 'javascript:alert(i18n("javascripts.site.history_zoom_alert"));';
      node.title = i18n("javascripts.site.history_disabled_tooltip");
      node.addClassName("disabled");
    }
  }

  node = $("shortlinkanchor");
  if (node) {
    var args = getArgs(node.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 (B000FTF) from
    // the shortlink. B000FTFT is then the "Object" layer which we get
    // on /?{node,way,relation}=id
    if (layers && (layers != "B000FTF") && (layers != "B000FTFT")) {
      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]) {
      node.href = setArgs(prefix + "/go/" + code, args);
    } else {
      node.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 "";<commit_msg>Fix short links to drop the layers param for the default layer<commit_after>
/*
 * 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) {
  var decimals = Math.pow(10, Math.floor(zoom/3));
  var node;

  lat = Math.round(lat * decimals) / decimals;
  lon = Math.round(lon * decimals) / decimals;

  node = $("permalinkanchor");
  if (node) {
    var args = getArgs(node.href);
    args["lat"] = lat;
    args["lon"] = lon;
    args["zoom"] = zoom;
    if (layers) {
      args["layers"] = layers;
    }
    if (objtype && objid) {
      args[objtype] = objid;
    }
    node.href = setArgs(node.href, args);
  }

  node = $("viewanchor");
  if (node) {
    var args = getArgs(node.href);
    args["lat"] = lat;
    args["lon"] = lon;
    args["zoom"] = zoom;
    if (layers) {
      args["layers"] = layers;
    }
    node.href = setArgs(node.href, args);
  }

  node = $("exportanchor");
  if (node) {
    var args = getArgs(node.href);
    args["lat"] = lat;
    args["lon"] = lon;
    args["zoom"] = zoom;
    if (layers) {
      args["layers"] = layers;
    }
    node.href = setArgs(node.href, args);
  }

  node = $("editanchor");
  if (node) {
    if (zoom >= 13) {
      var args = new Object();
      args.lat = lat;
      args.lon = lon;
      args.zoom = zoom;
      if (objtype && objid) {
        args[objtype] = objid;
      }
      node.href = setArgs("/edit", args);
      node.title = i18n("javascripts.site.edit_tooltip");
      node.removeClassName("disabled");
    } else {
      node.href = 'javascript:alert(i18n("javascripts.site.edit_zoom_alert"));';
      node.title = i18n("javascripts.site.edit_disabled_tooltip");
      node.addClassName("disabled");
    }
  }

  node = $("historyanchor");
  if (node) {
    if (zoom >= 11) {
      var args = new Object();
      //set bbox param from 'extents' object
      if (typeof minlon == "number" &&
	  typeof minlat == "number" &&
	  typeof maxlon == "number" &&
	  typeof maxlat == "number") {

        minlon = Math.round(minlon * decimals) / decimals;
        minlat = Math.round(minlat * decimals) / decimals;
        maxlon = Math.round(maxlon * decimals) / decimals;
        maxlat = Math.round(maxlat * decimals) / decimals;
        args.bbox = minlon + "," + minlat + "," + maxlon + "," + maxlat;
      }

      node.href = setArgs("/history", args);
      node.title = i18n("javascripts.site.history_tooltip");
      node.removeClassName("disabled");
    } else {
      node.href = 'javascript:alert(i18n("javascripts.site.history_zoom_alert"));';
      node.title = i18n("javascripts.site.history_disabled_tooltip");
      node.addClassName("disabled");
    }
  }

  node = $("shortlinkanchor");
  if (node) {
    var args = getArgs(node.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]) {
      node.href = setArgs(prefix + "/go/" + code, args);
    } else {
      node.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 "";
{'fraction_non_alphanumeric': 0.16127800407331974, 'fraction_numerical': 0.006364562118126273, 'mean_word_length': 2.6090950849793293, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '90519', 'n_tokens_mistral': 2715, 'n_tokens_neox': 2612, 'n_words': 645}