<commit_before>/*global  window, jQuery, $, OpenLayers, language, UserVoice, uservoiceOptions, _gaq*/
/*jslint devel: true, browser: true, maxerr: 200, indent: 2, sloppy: true, nomen: true */

jQuery.migrateMute = true;

jQuery.parseQuery = function(qs,options) {
  var q = (typeof qs === 'string'?qs:window.location.search), o = {'f':function(v){return unescape(v).replace(/\+/g,' ');}}, options = (typeof qs === 'object' && typeof options === 'undefined')?qs:options, o = jQuery.extend({}, o, options), params = {};
  jQuery.each(q.match(/^\??(.*)$/)[1].split('&'),function(i,p){
    p = p.split('=');
    p[1] = o.f(p[1]);
    params[p[0]] = params[p[0]]?((params[p[0]] instanceof Array)?(params[p[0]].push(p[1]),params[p[0]]):[params[p[0]],p[1]]):p[1];
  });
  return params;
}

var map;
var epsg4326, epsg900913;
if (!window.zoom) {
  var zoom = 14;
}

var places = [];
var mapnik;
var draggable;

OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
// OpenLayers.ImgPath = "http://js.mapbox.com/theme/dark/";
// OpenLayers.ImgPath = "http://wheelmap.local/img/";
OpenLayers.ImgPath = 'http://asset0.' + location.host + '/img/';

function runEffect() {
  setTimeout(function () {
    var selectedEffect = 'blind';
    var options = {};
    $(".flash").fadeOut();
  }, 5000);
}

function add_socia_script (d, t, src) {
  var g = d.createElement(t),
  s = d.getElementsByTagName(t)[0];
  g.async = true;
  g.src = src;
  s.parentNode.insertBefore(g, s);
};

function removeAllPopups() {
  $.each(map.popups, function (i, popup) {
    popup.feature = null;
    map.removePopup(popup);
  });
}


function submit_handler() {
  var form = $(this);
  if ((form.find('input:checked').val()) === 'unknown') {
    return false;
  }
  $('#update_button').attr('disabled', 'disabled');
  $('#update_spinner').show();

  $.ajax({ dataType: 'json', type: form.attr('method'), url: form.attr('action'), data: form.serialize(),
    success: function (data, textStatus, XMLHttpRequest) {
      $('#map').after('<div class="flash" id="notice">' + data.message + '<a href="#" data="hide">x</a></div>');

      runEffect();
      removeAllPopups();
      $('#update_spinner').hide();
      $('#update_button').removeAttr('disabled');
      if (window._gaq) {
        _gaq.push(['_trackEvent', 'Data', 'Tag', data.wheelchair]);
      }
      return false;
    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
      $('#map').after('<div class="flash" id="alert">' + textStatus + '<a href="#" data="hide">x</a></div>');
      $('#update_spinner').hide();
      $('#update_button').removeAttr('disabled');
      if (window._gaq) {
        _gaq.push(['_trackEvent', 'Data', 'Tag', 'failed']);
      }
      return false;
    }
  });
  return false;
}


function jumpTo(lon, lat, zoom) {
  var lonlat = new OpenLayers.LonLat(lon, lat).transform(
    epsg4326, //transform from WGS 1984
    map.getProjectionObject()               //to Spherical Mercator Projection
  );
  map.setCenter(lonlat, zoom);
  $.cookie('last_lat', lat, { expires: 7, path: '/'});
  $.cookie('last_lon', lon, { expires: 7, path: '/'});
  return false;
}

function drawmap(controls, element) {
  OpenLayers.Lang.setCode(language);

  epsg900913 = new OpenLayers.Projection("EPSG:900913");
  epsg4326 = new OpenLayers.Projection("EPSG:4326");
  map = new OpenLayers.Map(element, {
    projection: epsg900913,
    displayProjection: epsg4326,
    controls: controls,
    maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
    numZoomLevels: 19,
    maxResolution: 156543.0399,
    units: 'm',
    theme: null

  });

  mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", { displayClass: 'olMap', opacity: 1.0, transitionEffect: 'resize', numZoomLevels: 19, buffer: 1});

  // Use for offline mode
  // mapnik = new OpenLayers.Layer.OSM("Mapnik", 'http://wheelmap.local/images/tiles/${z}/${x}/${y}.png' ,{displayClass:'olMap', opacity:0.5, transitionEffect:'resize', numZoomLevels: 19});

  // User cloudmade style
  //  mapnik = new OpenLayers.Layer.CloudMade("CloudMade", {
  //     key: '<KEY>',
  //     styleId: 1714,
  //     displayClass:'olMap',
  //     opacity:1.0,
  //     transitionEffect:'resize',
  //     numZoomLevels: 19
  // });

  map.addLayers([mapnik]);
}

function defaultControls(map_id) {
  return [
    new OpenLayers.Control.ArgParser(),
    new OpenLayers.Control.Attribution({id: 'attribution', displayClass: "olControlAttribution"}),
    new OpenLayers.Control.PanZoomBar({id: 'panzoombar', displayClass: 'olControlPanZoomBar'}),
    new OpenLayers.Control.Navigation({zoomWheelEnabled: true, autoActivate: true, dragPanOptions: {enableKinetic: true}}),
    new OpenLayers.Control.KeyboardDefaults({observeElement: map_id}),
    new OpenLayers.Control.ScaleLine({geodesic: true}),
    new OpenLayers.Control.Permalink(),
    new OpenLayers.Control.Permalink('createlink', '/nodes/new')
  ];
}

function centerCoordinates() {
  return map.center.clone().transform(map.getProjectionObject(), epsg4326);
}

/* Callback function when map finished zooming. */
function onZoomEnd() {
  $.cookie('last_zoom', map.getZoom(), { expires: 7, path: '/'});
}

/* Callback function when map finished panning. */
function onMoveEnd() {
  var lonlat = centerCoordinates();
  $.cookie('last_lat', lonlat.lat);
  $.cookie('last_lon', lonlat.lon);
}

function showSpinner() {
  $('#spinner').show();
}

function hideSpinner() {
  $('#spinner').hide();
}

/* Callback function when map data is loaded. */
function onLoadStart() {
  showSpinner();
}

/* Callback function after map data was loaded. */
function onLoadEnd() {
  hideSpinner();
}

function addState(feature) {

}

function lonLatToMercator(ll) {
  // var lon = ll.lon * 20037508.34 / 180;
  var lon = ll.lon * 111319.49077777777;
  // var lat = Math.log(Math.tan((90 + ll.lat) * Math.PI / 360)) / (Math.PI / 180);
  var lat = Math.log(Math.tan((90 + ll.lat) * 0.008726646259971648)) / (0.017453292519943295);
  // lat = lat * 20037508.34 / 180;
  lat = lat * 111319.49077777777;
  return new OpenLayers.LonLat(lon, lat);
}

function placesStyle() {
  return new OpenLayers.StyleMap({
    "default": new OpenLayers.Style({
      graphicTitle: "${all}",
      graphicName: "circle",
      label: "${label}",
      fontColor: "#FFF",
      fontWeight: "bold",
      fontSize: "13px",
      fillColor: "${color}",
      fillOpacity: "${opacity}",
      strokeColor: "${color}",
      strokeOpacity: 0.7,
      strokeWidth: "2",
      strokeDashstyle: "solid",
      pointRadius: "${radius}",
      cursor: "pointer",
      externalGraphic: "${marker}",
      graphicWidth: 32,
      graphicHeight: 37,
      graphicXOffset: -16,
      graphicYOffset: -33,
      graphicZIndex: "${zindex}",
      backgroundGraphicZIndex: 10
    },{
      context: {
        all: function(feature) {
          if (feature.cluster) {
            feature.attributes.marker = '';
            feature.attributes.radius = 10 + (4 * Math.sqrt(feature.cluster.length));
            feature.attributes.opacity = 0.25;
            feature.attributes.zindex = 15;
            feature.attributes.color = '#8D8D8E';
            feature.attributes.label = feature.cluster.length;
          } else {<commit_msg>Fix marker icon on node detail page. [FIXES #49490295]<commit_after>/*global  window, jQuery, $, OpenLayers, language, UserVoice, uservoiceOptions, _gaq*/
/*jslint devel: true, browser: true, maxerr: 200, indent: 2, sloppy: true, nomen: true */

jQuery.migrateMute = true;

jQuery.parseQuery = function(qs,options) {
  var q = (typeof qs === 'string'?qs:window.location.search), o = {'f':function(v){return unescape(v).replace(/\+/g,' ');}}, options = (typeof qs === 'object' && typeof options === 'undefined')?qs:options, o = jQuery.extend({}, o, options), params = {};
  jQuery.each(q.match(/^\??(.*)$/)[1].split('&'),function(i,p){
    p = p.split('=');
    p[1] = o.f(p[1]);
    params[p[0]] = params[p[0]]?((params[p[0]] instanceof Array)?(params[p[0]].push(p[1]),params[p[0]]):[params[p[0]],p[1]]):p[1];
  });
  return params;
}

var map;
var epsg4326, epsg900913;
if (!window.zoom) {
  var zoom = 14;
}

var places = [];
var mapnik;
var draggable;

OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
// OpenLayers.ImgPath = "http://js.mapbox.com/theme/dark/";
// OpenLayers.ImgPath = "http://wheelmap.local/img/";
OpenLayers.ImgPath = 'http://asset0.' + location.host + '/img/';

function runEffect() {
  setTimeout(function () {
    var selectedEffect = 'blind';
    var options = {};
    $(".flash").fadeOut();
  }, 5000);
}

function add_socia_script (d, t, src) {
  var g = d.createElement(t),
  s = d.getElementsByTagName(t)[0];
  g.async = true;
  g.src = src;
  s.parentNode.insertBefore(g, s);
};

function removeAllPopups() {
  $.each(map.popups, function (i, popup) {
    popup.feature = null;
    map.removePopup(popup);
  });
}


function submit_handler() {
  var form = $(this);
  if ((form.find('input:checked').val()) === 'unknown') {
    return false;
  }
  $('#update_button').attr('disabled', 'disabled');
  $('#update_spinner').show();

  $.ajax({ dataType: 'json', type: form.attr('method'), url: form.attr('action'), data: form.serialize(),
    success: function (data, textStatus, XMLHttpRequest) {
      $('#map').after('<div class="flash" id="notice">' + data.message + '<a href="#" data="hide">x</a></div>');

      runEffect();
      removeAllPopups();
      $('#update_spinner').hide();
      $('#update_button').removeAttr('disabled');
      if (window._gaq) {
        _gaq.push(['_trackEvent', 'Data', 'Tag', data.wheelchair]);
      }
      return false;
    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
      $('#map').after('<div class="flash" id="alert">' + textStatus + '<a href="#" data="hide">x</a></div>');
      $('#update_spinner').hide();
      $('#update_button').removeAttr('disabled');
      if (window._gaq) {
        _gaq.push(['_trackEvent', 'Data', 'Tag', 'failed']);
      }
      return false;
    }
  });
  return false;
}


function jumpTo(lon, lat, zoom) {
  var lonlat = new OpenLayers.LonLat(lon, lat).transform(
    epsg4326, //transform from WGS 1984
    map.getProjectionObject()               //to Spherical Mercator Projection
  );
  map.setCenter(lonlat, zoom);
  $.cookie('last_lat', lat, { expires: 7, path: '/'});
  $.cookie('last_lon', lon, { expires: 7, path: '/'});
  return false;
}

function drawmap(controls, element) {
  OpenLayers.Lang.setCode(language);

  epsg900913 = new OpenLayers.Projection("EPSG:900913");
  epsg4326 = new OpenLayers.Projection("EPSG:4326");
  map = new OpenLayers.Map(element, {
    projection: epsg900913,
    displayProjection: epsg4326,
    controls: controls,
    maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
    numZoomLevels: 19,
    maxResolution: 156543.0399,
    units: 'm',
    theme: null

  });

  mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", { displayClass: 'olMap', opacity: 1.0, transitionEffect: 'resize', numZoomLevels: 19, buffer: 1});

  // Use for offline mode
  // mapnik = new OpenLayers.Layer.OSM("Mapnik", 'http://wheelmap.local/images/tiles/${z}/${x}/${y}.png' ,{displayClass:'olMap', opacity:0.5, transitionEffect:'resize', numZoomLevels: 19});

  // User cloudmade style
  //  mapnik = new OpenLayers.Layer.CloudMade("CloudMade", {
  //     key: '<KEY>',
  //     styleId: 1714,
  //     displayClass:'olMap',
  //     opacity:1.0,
  //     transitionEffect:'resize',
  //     numZoomLevels: 19
  // });

  map.addLayers([mapnik]);
}

function defaultControls(map_id) {
  return [
    new OpenLayers.Control.ArgParser(),
    new OpenLayers.Control.Attribution({id: 'attribution', displayClass: "olControlAttribution"}),
    new OpenLayers.Control.PanZoomBar({id: 'panzoombar', displayClass: 'olControlPanZoomBar'}),
    new OpenLayers.Control.Navigation({zoomWheelEnabled: true, autoActivate: true, dragPanOptions: {enableKinetic: true}}),
    new OpenLayers.Control.KeyboardDefaults({observeElement: map_id}),
    new OpenLayers.Control.ScaleLine({geodesic: true}),
    new OpenLayers.Control.Permalink(),
    new OpenLayers.Control.Permalink('createlink', '/nodes/new')
  ];
}

function centerCoordinates() {
  return map.center.clone().transform(map.getProjectionObject(), epsg4326);
}

/* Callback function when map finished zooming. */
function onZoomEnd() {
  $.cookie('last_zoom', map.getZoom(), { expires: 7, path: '/'});
}

/* Callback function when map finished panning. */
function onMoveEnd() {
  var lonlat = centerCoordinates();
  $.cookie('last_lat', lonlat.lat);
  $.cookie('last_lon', lonlat.lon);
}

function showSpinner() {
  $('#spinner').show();
}

function hideSpinner() {
  $('#spinner').hide();
}

/* Callback function when map data is loaded. */
function onLoadStart() {
  showSpinner();
}

/* Callback function after map data was loaded. */
function onLoadEnd() {
  hideSpinner();
}

function addState(feature) {

}

function lonLatToMercator(ll) {
  // var lon = ll.lon * 20037508.34 / 180;
  var lon = ll.lon * 111319.49077777777;
  // var lat = Math.log(Math.tan((90 + ll.lat) * Math.PI / 360)) / (Math.PI / 180);
  var lat = Math.log(Math.tan((90 + ll.lat) * 0.008726646259971648)) / (0.017453292519943295);
  // lat = lat * 20037508.34 / 180;
  lat = lat * 111319.49077777777;
  return new OpenLayers.LonLat(lon, lat);
}

function placesStyle() {
  return new OpenLayers.StyleMap({
    "default": new OpenLayers.Style({
      graphicTitle: "${all}",
      graphicName: "circle",
      label: "${label}",
      fontColor: "#FFF",
      fontWeight: "bold",
      fontSize: "13px",
      fillColor: "${color}",
      fillOpacity: "${opacity}",
      strokeColor: "${color}",
      strokeOpacity: 0.7,
      strokeWidth: "2",
      strokeDashstyle: "solid",
      pointRadius: "${radius}",
      cursor: "pointer",
      externalGraphic: "http://asset0.wheelmap.org/marker/undefined.png",
      graphicWidth: 32,
      graphicHeight: 37,
      graphicXOffset: -16,
      graphicYOffset: -33,
      graphicZIndex: "${zindex}",
      backgroundGraphicZIndex: 10
    },{
      context: {
        all: function(feature) {
          if (feature.cluster) {
            feature.attributes.marker = '';
            feature.attributes.radius = 10 + (4 * Math.sqrt(feature.cluster.length));
            feature.attributes.opacity = 0.25;
            feature.attributes.zindex = 15;
            feature.attributes.color = '#8D8D8E';
            feature.attributes.label = feature.cluster.length;
          } else {
{'fraction_non_alphanumeric': 0.1855464724874631, 'fraction_numerical': 0.03949989695679055, 'mean_word_length': 3.5650674192536846, 'pattern_counts': {'":': 2, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '3202418', 'n_tokens_mistral': 5424, 'n_tokens_neox': 4988, 'n_words': 998}