args = querystring.parse(link.search.substring(1)),
editlink = $(link).hasClass("editlink");
- delete args['node'];
- delete args['way'];
- delete args['relation'];
- delete args['changeset'];
+ delete args.node;
+ delete args.way;
+ delete args.relation;
+ delete args.changeset;
if (object && editlink) {
args[object.type] = object.id;
'"': '"',
"'": '''
};
- return string == null ? '' : (string + '').replace(/[&<>"']/g, function(match) {
+ return string === null ? '' : (string + '').replace(/[&<>"']/g, function(match) {
return htmlEscapes[match];
});
}
var map = L.map("map");
map.attributionControl.setPrefix('');
- if (!args.layer || args.layer == "mapnik" || args.layer == "osmarender") {
+ if (!args.layer || args.layer === "mapnik" || args.layer === "osmarender") {
new L.OSM.Mapnik().addTo(map);
- } else if (args.layer == "cyclemap" || args.layer == "cycle map") {
+ } else if (args.layer === "cyclemap" || args.layer === "cycle map") {
new L.OSM.CycleMap().addTo(map);
- } else if (args.layer == "transportmap") {
+ } else if (args.layer === "transportmap") {
new L.OSM.TransportMap().addTo(map);
- } else if (args.layer == "mapquest") {
+ } else if (args.layer === "mapquest") {
new L.OSM.MapQuestOpen().addTo(map);
- } else if (args.layer == "hot") {
+ } else if (args.layer === "hot") {
new L.OSM.HOT().addTo(map);
}
if (args.bbox) {
var bbox = args.bbox.split(',');
map.fitBounds([L.latLng(bbox[1], bbox[0]),
- L.latLng(bbox[3], bbox[2])])
+ L.latLng(bbox[3], bbox[2])]);
} else {
map.fitWorld();
}
// IE<10 doesn't respect Vary: X-Requested-With header, so
// prevent caching the XHR response as a full-page URL.
if (path.indexOf('?') >= 0) {
- path += '&xhr=1'
+ path += '&xhr=1';
} else {
- path += '?xhr=1'
+ path += '?xhr=1';
}
$('#sidebar_content')
L.control.scale()
.addTo(map);
- if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') {
+ if (OSM.STATUS !== 'api_offline' && OSM.STATUS !== 'database_offline') {
initializeNotes(map);
if (params.layers.indexOf(map.noteLayer.options.code) >= 0) {
map.addLayer(map.noteLayer);
$.cookie("_osm_location", OSM.locationCookie(map), { expires: expiry, path: "/" });
});
- if ($.cookie('_osm_welcome') == 'hide') {
+ if ($.cookie('_osm_welcome') === 'hide') {
$('.welcome').hide();
}
};
function addObject(type, id, center) {
- var bounds = map.addObject({type: type, id: parseInt(id)}, function(bounds) {
+ map.addObject({type: type, id: parseInt(id)}, function(bounds) {
if (!window.location.hash && bounds.isValid() &&
(center || !map.getBounds().contains(bounds))) {
OSM.router.withoutMoveListener(function () {
"/query": OSM.Query(map)
});
- if (OSM.preferred_editor == "remote" && document.location.pathname == "/edit") {
+ if (OSM.preferred_editor === "remote" && document.location.pathname === "/edit") {
remoteEditHandler(map.getBounds(), params.object);
OSM.router.setCurrentPath("/");
}
};
function addChangeset(id, center) {
- var bounds = map.addObject({type: 'changeset', id: parseInt(id)}, function(bounds) {
+ map.addObject({type: 'changeset', id: parseInt(id)}, function(bounds) {
if (!window.location.hash && bounds.isValid() &&
(center || !map.getBounds().contains(bounds))) {
OSM.router.withoutMoveListener(function () {
}
function updateChangeset(form, method, url, include_data) {
+ var data;
+
$(form).find("input[type=submit]").prop("disabled", true);
+
if(include_data) {
data = {text: $(form.text).val()};
} else {
content.find("textarea").on("input", function (e) {
var form = e.target.form;
- if ($(e.target).val() == "") {
+ if ($(e.target).val() === "") {
$(form.comment).prop("disabled", true);
} else {
$(form.comment).prop("disabled", false);
});
content.find("textarea").val('').trigger("input");
- };
+ }
page.unload = function() {
map.removeObject();
};
return page;
-};
\ No newline at end of file
+};
});
endpoint.marker.on('drag dragend', function (e) {
- dragging = (e.type == 'drag');
+ dragging = (e.type === 'drag');
if (dragging && !chosenEngine.draggable) return;
if (dragging && awaitingRoute) return;
endpoint.setLatLng(e.target.getLatLng());
input.on("change", function (e) {
// make text the same in both text boxes
var value = e.target.value;
- endpoint.setValue(value)
+ endpoint.setValue(value);
});
endpoint.setValue = function(value) {
delete endpoint.latlng;
input.val(value);
endpoint.getGeocode();
- }
+ };
endpoint.getGeocode = function() {
// if no one has entered a value yet, then we can't geocode, so don't
$.getJSON(document.location.protocol + OSM.NOMINATIM_URL + 'search?q=' + encodeURIComponent(endpoint.value) + '&format=json', function (json) {
endpoint.awaitingGeocode = false;
endpoint.hasGeocode = true;
- if (json.length == 0) {
+ if (json.length === 0) {
alert(I18n.t('javascripts.directions.errors.no_place'));
return;
}
getRoute();
}
});
- }
+ };
endpoint.setLatLng = function (ll) {
var precision = OSM.zoomPrecision(map.getZoom());
function setEngine(id) {
engines.forEach(function(engine, i) {
- if (engine.id == id) {
+ if (engine.id === id) {
chosenEngine = engine;
select.val(i);
}
OSM.Directions.engines = [];
OSM.Directions.addEngine = function (engine, supportsHTTPS) {
- if (document.location.protocol == "http:" || supportsHTTPS) {
+ if (document.location.protocol === "http:" || supportsHTTPS) {
OSM.Directions.engines.push(engine);
}
};
getRoute: function (points, callback) {
// documentation
// https://github.com/graphhopper/graphhopper/blob/master/docs/web/api-doc.md
- var url = document.location.protocol + "//graphhopper.com/api/1/route?"
- + vehicleParam
- + "&locale=" + I18n.currentLocale()
- + "&key=LijBPDQGfu7Iiq80w3HzwB4RUDJbMbhs6BU0dEnn"
- + "&type=jsonp"
- + "&instructions=true";
+ var url = document.location.protocol + "//graphhopper.com/api/1/route?" +
+ vehicleParam +
+ "&locale=" + I18n.currentLocale() +
+ "&key=LijBPDQGfu7Iiq80w3HzwB4RUDJbMbhs6BU0dEnn" +
+ "&type=jsonp" +
+ "&instructions=true";
for (var i = 0; i < points.length; i++) {
url += "&point=" + points[i].lat + ',' + points[i].lng;
url: url,
dataType: 'jsonp',
success: function (data) {
- if (!data.paths || data.paths.length == 0)
+ if (!data.paths || data.paths.length === 0)
return callback(true);
var path = data.paths[0];
};
}
-OSM.Directions.addEngine(GraphHopperEngine("graphhopper_bicycle", "vehicle=bike"), true);
-OSM.Directions.addEngine(GraphHopperEngine("graphhopper_foot", "vehicle=foot"), true);
+OSM.Directions.addEngine(new GraphHopperEngine("graphhopper_bicycle", "vehicle=bike"), true);
+OSM.Directions.addEngine(new GraphHopperEngine("graphhopper_foot", "vehicle=foot"), true);
$.ajax({
url: url,
success: function (data) {
- if (data.info.statuscode != 0)
+ if (data.info.statuscode !== 0)
return callback(true);
var line = [];
var d;
var linesegstart, linesegend, lineseg;
linesegstart = data.route.shape.maneuverIndexes[i];
- if (i == mq.length - 1) {
+ if (i === mq.length - 1) {
d = 15;
linesegend = linesegstart + 1;
} else {
line: line,
steps: steps,
distance: data.route.distance * 1000,
- time: data.route['time']
+ time: data.route.time
});
}
});
};
}
-OSM.Directions.addEngine(MapQuestEngine("mapquest_bicycle", "routeType=bicycle"), true);
-OSM.Directions.addEngine(MapQuestEngine("mapquest_foot", "routeType=pedestrian"), true);
-OSM.Directions.addEngine(MapQuestEngine("mapquest_car", "routeType=fastest"), true);
+OSM.Directions.addEngine(new MapQuestEngine("mapquest_bicycle", "routeType=bicycle"), true);
+OSM.Directions.addEngine(new MapQuestEngine("mapquest_foot", "routeType=pedestrian"), true);
+OSM.Directions.addEngine(new MapQuestEngine("mapquest_car", "routeType=fastest"), true);
url: url,
dataType: 'json',
success: function (data) {
- if (data.status == 207)
+ if (data.status === 207)
return callback(true);
previousPoints = points;
if (instCodes[1]) {
instText += "exit " + instCodes[1] + " ";
}
- if (instCodes[0] != 15) {
+ if (instCodes[0] !== 15) {
instText += s[1] ? "<b>" + s[1] + "</b>" : I18n.t('javascripts.directions.instructions.unnamed');
}
if ((i + 1) < data.route_instructions.length) {
};
}
-OSM.Directions.addEngine(OSRMEngine(), true);
+OSM.Directions.addEngine(new OSRMEngine(), true);
url: window.location.pathname,
method: "GET",
data: data,
- success: function(html, status, xhr) {
+ success: function(html) {
$('#sidebar_content .changesets').html(html);
updateMap();
}
};
function newHalo(loc, a) {
- if (a == 'dragstart' && map.hasLayer(halo)) {
+ if (a === 'dragstart' && map.hasLayer(halo)) {
map.removeLayer(halo);
} else {
if (map.hasLayer(halo)) map.removeLayer(halo);
content.find("textarea").on("input", function (e) {
var form = e.target.form;
- if ($(e.target).val() == "") {
+ if ($(e.target).val() === "") {
$(form.close).val(I18n.t("javascripts.notes.show.resolve"));
$(form.comment).prop("disabled", true);
} else {
map.addLayer(currentNote);
if (callback) callback();
- };
+ }
function moveToNote() {
var data = $('.details').data(),
};
map.on("layeradd", function (e) {
- if (e.layer == noteLayer) {
+ if (e.layer === noteLayer) {
loadNotes();
map.on("moveend", loadNotes);
}
}).on("layerremove", function (e) {
- if (e.layer == noteLayer) {
+ if (e.layer === noteLayer) {
map.off("moveend", loadNotes);
noteLayer.clearLayers();
notes = {};
} else if (!queryButton.hasClass("disabled")) {
enableQueryMode();
}
- }).on("disabled", function (e) {
+ }).on("disabled", function () {
if (queryButton.hasClass("active")) {
map.off("click", clickHandler);
$(map.getContainer()).removeClass("query-active").addClass("query-disabled");
$(this).tooltip("show");
}
- }).on("enabled", function (e) {
+ }).on("enabled", function () {
if (queryButton.hasClass("active")) {
map.on("click", clickHandler);
$(map.getContainer()).removeClass("query-disabled").addClass("query-active");
$("#sidebar_content")
.on("mouseover", ".query-results li.query-result", function () {
- var geometry = $(this).data("geometry")
+ var geometry = $(this).data("geometry");
if (geometry) map.addLayer(geometry);
$(this).addClass("selected");
})
.on("mouseout", ".query-results li.query-result", function () {
- var geometry = $(this).data("geometry")
+ var geometry = $(this).data("geometry");
if (geometry) map.removeLayer(geometry);
$(this).removeClass("selected");
})
- .on("mousedown", ".query-results li.query-result", function (e) {
+ .on("mousedown", ".query-results li.query-result", function () {
var moved = false;
$(this).one("click", function (e) {
if (!moved) {
- var geometry = $(this).data("geometry")
+ var geometry = $(this).data("geometry");
if (geometry) map.removeLayer(geometry);
if (!$(e.target).is('a')) {
});
});
- function interestingFeature(feature, origin, radius) {
+ function interestingFeature(feature) {
if (feature.tags) {
for (var key in feature.tags) {
if (uninterestingTags.indexOf(key) < 0) {
var prefix = "";
if (tags.boundary === "administrative" && tags.admin_level) {
- prefix =
- I18n.t("geocoder.search_osm_nominatim.admin_levels.level" + tags.admin_level, {
+ prefix = I18n.t("geocoder.search_osm_nominatim.admin_levels.level" + tags.admin_level, {
defaultValue: I18n.t("geocoder.search_osm_nominatim.prefix.boundary.administrative")
- })
+ });
} else {
var prefixes = I18n.t("geocoder.search_osm_nominatim.prefix");
}
}
- if (tags["name"]) {
- return tags["name"];
- } else if (tags["ref"]) {
- return tags["ref"];
+ if (tags.name) {
+ return tags.name;
+ } else if (tags.ref) {
+ return tags.ref;
} else if (tags["addr:housename"]) {
return tags["addr:housename"];
} else if (tags["addr:housenumber"] && tags["addr:street"]) {
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
- if (interestingFeature(element, latlng, radius)) {
+ if (interestingFeature(element)) {
var $li = $("<li>")
.addClass("query-result")
.data("geometry", featureGeometry(element))
}
}
- if ($ul.find("li").length == 0) {
+ if ($ul.find("li").length === 0) {
$("<li>")
.text(I18n.t("javascripts.query.nothing_found"))
.appendTo($ul);
marker = L.circle(latlng, radius, featureStyle).addTo(map);
$(document).everyTime(75, "fadeQueryMarker", function (i) {
- if (i == 10) {
+ if (i === 10) {
map.removeLayer(marker);
} else {
marker.setStyle({
OSM.Search = function(map) {
$(".search_form input[name=query]").on("input", function(e) {
- if ($(e.target).val() == "") {
+ if ($(e.target).val() === "") {
$(".describe_location").fadeIn(100);
} else {
$(".describe_location").fadeOut(100);
});
}
- function showSearchResult(e) {
+ function showSearchResult() {
var marker = $(this).data("marker");
if (!marker) {
$(this).closest("li").addClass("selected");
}
- function hideSearchResult(e) {
+ function hideSearchResult() {
var marker = $(this).data("marker");
if (marker) {
}
function updateButton() {
- var disabled = map.getMapBaseLayerId() !== 'mapnik'
+ var disabled = map.getMapBaseLayerId() !== 'mapnik';
button
.toggleClass('disabled', disabled)
- .attr('data-original-title', I18n.t(disabled ?
- 'javascripts.key.tooltip_disabled' :
- 'javascripts.key.tooltip'))
+ .attr('data-original-title',
+ I18n.t(disabled ?
+ 'javascripts.key.tooltip_disabled' :
+ 'javascripts.key.tooltip'));
}
function update() {
$('.mapkey-table-entry').each(function () {
var data = $(this).data();
- if (layer == data.layer && zoom >= data.zoomMin && zoom <= data.zoomMax) {
+ if (layer === data.layer && zoom >= data.zoomMin && zoom <= data.zoomMax) {
$(this).show();
} else {
$(this).hide();
});
});
- if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') {
+ if (OSM.STATUS !== 'api_offline' && OSM.STATUS !== 'database_offline') {
var overlaySection = $('<div>')
.attr('class', 'section overlay-layers')
.appendTo($ui);
var list = $('<ul>')
.appendTo(overlaySection);
- function addOverlay(layer, name, maxArea) {
+ var addOverlay = function (layer, name, maxArea) {
var item = $('<li>')
.tooltip({
placement: 'top'
item.attr('data-original-title', disabled ?
I18n.t('javascripts.site.map_' + name + '_zoom_in_tooltip') : '');
});
- }
+ };
addOverlay(map.noteLayer, 'notes', OSM.MAX_NOTE_REQUEST_AREA);
addOverlay(map.dataLayer, 'data', OSM.MAX_REQUEST_AREA);
if (layerParam.indexOf(this.baseLayers[i].options.code) >= 0) {
this.addLayer(this.baseLayers[i]);
layersAdded = layersAdded + this.baseLayers[i].options.code;
- } else if (i == 0 && layersAdded == "") {
+ } else if (i === 0 && layersAdded === "") {
this.addLayer(this.baseLayers[i]);
} else {
this.removeLayer(this.baseLayers[i]);
return true;
} else if (object.type === "relation") {
for (var i = 0; i < relations.length; i++)
- if (relations[i].members.indexOf(node) != -1)
+ if (relations[i].members.indexOf(node) !== -1)
return true;
} else {
return false;
center: this.getCenter().wrap(),
zoom: this.getZoom(),
layers: this.getLayersCode()
- }
+ };
},
setState: function(state, options) {
map.on('zoomend', update);
- update();
-
function update() {
var disabled = OSM.STATUS === "database_offline" || map.getZoom() < 12;
link
'javascripts.site.createnote_tooltip'));
}
+ update();
+
return $container[0];
};
var width = editor.outerWidth() - preview.outerWidth() + preview.width();
var minHeight = editor.outerHeight() - preview.outerHeight() + preview.height();
- if (preview.contents().length == 0) {
+ if (preview.contents().length === 0) {
preview.oneTime(500, "loading", function () {
preview.addClass("loading");
});
var routes = [];
for (var r in rts)
- routes.push(Route(r, rts[r]));
+ routes.push(new Route(r, rts[r]));
routes.recognize = function(path) {
for (var i = 0; i < this.length; i++) {
$('.start-mapping').attr('href', url);
} else {
- function geoSuccess(position) {
+ var geoSuccess = function (position) {
window.location = '/edit' + OSM.formatHash({
zoom: 17,
lat: position.coords.latitude,
lon: position.coords.longitude
});
- }
+ };
$('.start-mapping').on('click', function(e) {
e.preventDefault();
*/
exports.parse = function(str){
- if ('string' != typeof str) return {};
+ if ('string' !== typeof str) return {};
str = trim(str);
- if ('' == str) return {};
+ if ('' === str) return {};
var obj = {};
var pairs = str.split('&');
for (var i = 0; i < pairs.length; i++) {
var parts = pairs[i].split('=');
- obj[parts[0]] = null == parts[1]
+ obj[parts[0]] = null === parts[1]
? ''
: decodeURIComponent(parts[1]);
}
};
},{}]},{},[])
-;
\ No newline at end of file
+;