<commit_before>/* this part must be in global namespace */
// fetch taxonomy, containing all translations, and implicit affiliations
// taken from Wikipedia:JSON
var url = "taxonomy.json";
var taxonomy;
var http_request = new XMLHttpRequest();
http_request.open("GET", url, true);
http_request.onreadystatechange = function () {
      var done = 4, ok = 200;
      if (http_request.readyState === done && http_request.status === ok) {
          taxonomy = JSON.parse(http_request.responseText);
      }
  };
http_request.send(null);

function toggleLayer(key,value) {
  alert(key + "=" + value);
}

function initMap(defaultlayer,base_maps,overlay_maps) {
  map = new L.Map('map', {
    center: new L.LatLng(47.07, 15.43),
      zoom: 13,
      layers: defaultlayer,
  });

  var ctrl = new L.Control.Layers(base_maps,overlay_maps)
  map.addControl(ctrl);

  L.LatLngBounds.prototype.toOverpassBBoxString = function (){
    var a = this._southWest,
        b = this._northEast;
    return [a.lat, a.lng, b.lat, b.lng].join(",");
  }

  var path_style = L.Path.prototype._updateStyle;
  L.Path.prototype._updateStyle = function () {
    path_style.apply(this);
    for (k in this.options.svg) {
      this._path.setAttribute(k, this.options.svg[k]);
    }
  }

  // handmade dynamic LayerSwitcher
  if (window.switch_layertags ) {
    $('body').append('<ul id="layerswitcher"></ul>');
    var layerswitcher =  document.getElementById("layerswitcher");
    for (var i = 0; i < switch_layertags.length; i++) {
      var current_item = switch_layertags[i]; // { key : value }
      var current_value,current_key;
      for (key in current_item) { // misusing 1-for-"loop" for extract key/value
        current_key = key;
        current_value = current_item[key];
      }
      var li = document.createElement("li");
      var textnode = document.createTextNode(current_key + " = " + current_value );
      li.appendChild( textnode);
      var functiontext = "toggleLayer('" + current_key + "','" + current_value + "');"
      li.setAttribute('onClick',functiontext);
      layerswitcher.appendChild( li );
      }
    layerswitcher.style.display = "none";
  }

  return map;
}

function addSearch() {
  map.addControl( new L.Control.Search({
    url: 'http://nominatim.openstreetmap.org/search?format=json&q={s}',
    jsonpParam: 'json_callback',
    propertyName: 'display_name',
    propertyLoc: ['lat','lon'],
    circleLocation: false,
    markerLocation: false,
    autoType: false,
    autoCollapse: false,
    minLength: 2,
    zoom:12
  }) );

}
function addLocate() {
lc = L.control.locate({
        position: 'topleft',
        showPopup: false,
        strings: {
                title: "Jump to my location!"<commit_msg>search box:default zoom to 16, because only then search for POIs makes sense<commit_after>/* this part must be in global namespace */
// fetch taxonomy, containing all translations, and implicit affiliations
// taken from Wikipedia:JSON
var url = "taxonomy.json";
var taxonomy;
var http_request = new XMLHttpRequest();
http_request.open("GET", url, true);
http_request.onreadystatechange = function () {
      var done = 4, ok = 200;
      if (http_request.readyState === done && http_request.status === ok) {
          taxonomy = JSON.parse(http_request.responseText);
      }
  };
http_request.send(null);

function toggleLayer(key,value) {
  alert(key + "=" + value);
}

function initMap(defaultlayer,base_maps,overlay_maps) {
  map = new L.Map('map', {
    center: new L.LatLng(47.07, 15.43),
      zoom: 13,
      layers: defaultlayer,
  });

  var ctrl = new L.Control.Layers(base_maps,overlay_maps)
  map.addControl(ctrl);

  L.LatLngBounds.prototype.toOverpassBBoxString = function (){
    var a = this._southWest,
        b = this._northEast;
    return [a.lat, a.lng, b.lat, b.lng].join(",");
  }

  var path_style = L.Path.prototype._updateStyle;
  L.Path.prototype._updateStyle = function () {
    path_style.apply(this);
    for (k in this.options.svg) {
      this._path.setAttribute(k, this.options.svg[k]);
    }
  }

  // handmade dynamic LayerSwitcher
  if (window.switch_layertags ) {
    $('body').append('<ul id="layerswitcher"></ul>');
    var layerswitcher =  document.getElementById("layerswitcher");
    for (var i = 0; i < switch_layertags.length; i++) {
      var current_item = switch_layertags[i]; // { key : value }
      var current_value,current_key;
      for (key in current_item) { // misusing 1-for-"loop" for extract key/value
        current_key = key;
        current_value = current_item[key];
      }
      var li = document.createElement("li");
      var textnode = document.createTextNode(current_key + " = " + current_value );
      li.appendChild( textnode);
      var functiontext = "toggleLayer('" + current_key + "','" + current_value + "');"
      li.setAttribute('onClick',functiontext);
      layerswitcher.appendChild( li );
      }
    layerswitcher.style.display = "none";
  }

  return map;
}

function addSearch() {
  map.addControl( new L.Control.Search({
    url: 'http://nominatim.openstreetmap.org/search?format=json&q={s}',
    jsonpParam: 'json_callback',
    propertyName: 'display_name',
    propertyLoc: ['lat','lon'],
    circleLocation: false,
    markerLocation: false,
    autoType: false,
    autoCollapse: false,
    minLength: 2,
    zoom:16
  }) );

}
function addLocate() {
lc = L.control.locate({
        position: 'topleft',
        showPopup: false,
        strings: {
                title: "Jump to my location!"
{'fraction_non_alphanumeric': 0.14132995107809385, 'fraction_numerical': 0.007247689798876608, 'mean_word_length': 3.2363775901765157, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7667059', 'n_tokens_mistral': 1833, 'n_tokens_neox': 1780, 'n_words': 387}