Fix some JSHint complaints

This commit is contained in:
Tom Hughes 2015-02-23 20:47:38 +00:00
parent 6671a934bf
commit 1596713871
22 changed files with 96 additions and 93 deletions

View file

@ -63,10 +63,10 @@ function updateLinks(loc, zoom, layers, object) {
args = querystring.parse(link.search.substring(1)), args = querystring.parse(link.search.substring(1)),
editlink = $(link).hasClass("editlink"); editlink = $(link).hasClass("editlink");
delete args['node']; delete args.node;
delete args['way']; delete args.way;
delete args['relation']; delete args.relation;
delete args['changeset']; delete args.changeset;
if (object && editlink) { if (object && editlink) {
args[object.type] = object.id; args[object.type] = object.id;
@ -108,7 +108,7 @@ function escapeHTML(string) {
'"': '"', '"': '"',
"'": ''' "'": '''
}; };
return string == null ? '' : (string + '').replace(/[&<>"']/g, function(match) { return string === null ? '' : (string + '').replace(/[&<>"']/g, function(match) {
return htmlEscapes[match]; return htmlEscapes[match];
}); });
} }

View file

@ -14,15 +14,15 @@ window.onload = function () {
var map = L.map("map"); var map = L.map("map");
map.attributionControl.setPrefix(''); 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); 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); new L.OSM.CycleMap().addTo(map);
} else if (args.layer == "transportmap") { } else if (args.layer === "transportmap") {
new L.OSM.TransportMap().addTo(map); new L.OSM.TransportMap().addTo(map);
} else if (args.layer == "mapquest") { } else if (args.layer === "mapquest") {
new L.OSM.MapQuestOpen().addTo(map); new L.OSM.MapQuestOpen().addTo(map);
} else if (args.layer == "hot") { } else if (args.layer === "hot") {
new L.OSM.HOT().addTo(map); new L.OSM.HOT().addTo(map);
} }
@ -39,7 +39,7 @@ window.onload = function () {
if (args.bbox) { if (args.bbox) {
var bbox = args.bbox.split(','); var bbox = args.bbox.split(',');
map.fitBounds([L.latLng(bbox[1], bbox[0]), map.fitBounds([L.latLng(bbox[1], bbox[0]),
L.latLng(bbox[3], bbox[2])]) L.latLng(bbox[3], bbox[2])]);
} else { } else {
map.fitWorld(); map.fitWorld();
} }

View file

@ -34,9 +34,9 @@ $(document).ready(function () {
// IE<10 doesn't respect Vary: X-Requested-With header, so // IE<10 doesn't respect Vary: X-Requested-With header, so
// prevent caching the XHR response as a full-page URL. // prevent caching the XHR response as a full-page URL.
if (path.indexOf('?') >= 0) { if (path.indexOf('?') >= 0) {
path += '&xhr=1' path += '&xhr=1';
} else { } else {
path += '?xhr=1' path += '?xhr=1';
} }
$('#sidebar_content') $('#sidebar_content')
@ -136,7 +136,7 @@ $(document).ready(function () {
L.control.scale() L.control.scale()
.addTo(map); .addTo(map);
if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') { if (OSM.STATUS !== 'api_offline' && OSM.STATUS !== 'database_offline') {
initializeNotes(map); initializeNotes(map);
if (params.layers.indexOf(map.noteLayer.options.code) >= 0) { if (params.layers.indexOf(map.noteLayer.options.code) >= 0) {
map.addLayer(map.noteLayer); map.addLayer(map.noteLayer);
@ -164,7 +164,7 @@ $(document).ready(function () {
$.cookie("_osm_location", OSM.locationCookie(map), { expires: expiry, path: "/" }); $.cookie("_osm_location", OSM.locationCookie(map), { expires: expiry, path: "/" });
}); });
if ($.cookie('_osm_welcome') == 'hide') { if ($.cookie('_osm_welcome') === 'hide') {
$('.welcome').hide(); $('.welcome').hide();
} }
@ -263,7 +263,7 @@ $(document).ready(function () {
}; };
function addObject(type, id, center) { 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() && if (!window.location.hash && bounds.isValid() &&
(center || !map.getBounds().contains(bounds))) { (center || !map.getBounds().contains(bounds))) {
OSM.router.withoutMoveListener(function () { OSM.router.withoutMoveListener(function () {
@ -300,7 +300,7 @@ $(document).ready(function () {
"/query": OSM.Query(map) "/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); remoteEditHandler(map.getBounds(), params.object);
OSM.router.setCurrentPath("/"); OSM.router.setCurrentPath("/");
} }

View file

@ -17,7 +17,7 @@ OSM.Changeset = function (map) {
}; };
function addChangeset(id, center) { 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() && if (!window.location.hash && bounds.isValid() &&
(center || !map.getBounds().contains(bounds))) { (center || !map.getBounds().contains(bounds))) {
OSM.router.withoutMoveListener(function () { OSM.router.withoutMoveListener(function () {
@ -28,7 +28,10 @@ OSM.Changeset = function (map) {
} }
function updateChangeset(form, method, url, include_data) { function updateChangeset(form, method, url, include_data) {
var data;
$(form).find("input[type=submit]").prop("disabled", true); $(form).find("input[type=submit]").prop("disabled", true);
if(include_data) { if(include_data) {
data = {text: $(form.text).val()}; data = {text: $(form.text).val()};
} else { } else {
@ -62,7 +65,7 @@ OSM.Changeset = function (map) {
content.find("textarea").on("input", function (e) { content.find("textarea").on("input", function (e) {
var form = e.target.form; var form = e.target.form;
if ($(e.target).val() == "") { if ($(e.target).val() === "") {
$(form.comment).prop("disabled", true); $(form.comment).prop("disabled", true);
} else { } else {
$(form.comment).prop("disabled", false); $(form.comment).prop("disabled", false);
@ -70,11 +73,11 @@ OSM.Changeset = function (map) {
}); });
content.find("textarea").val('').trigger("input"); content.find("textarea").val('').trigger("input");
}; }
page.unload = function() { page.unload = function() {
map.removeObject(); map.removeObject();
}; };
return page; return page;
}; };

View file

@ -42,7 +42,7 @@ OSM.Directions = function (map) {
}); });
endpoint.marker.on('drag dragend', function (e) { endpoint.marker.on('drag dragend', function (e) {
dragging = (e.type == 'drag'); dragging = (e.type === 'drag');
if (dragging && !chosenEngine.draggable) return; if (dragging && !chosenEngine.draggable) return;
if (dragging && awaitingRoute) return; if (dragging && awaitingRoute) return;
endpoint.setLatLng(e.target.getLatLng()); endpoint.setLatLng(e.target.getLatLng());
@ -54,7 +54,7 @@ OSM.Directions = function (map) {
input.on("change", function (e) { input.on("change", function (e) {
// make text the same in both text boxes // make text the same in both text boxes
var value = e.target.value; var value = e.target.value;
endpoint.setValue(value) endpoint.setValue(value);
}); });
endpoint.setValue = function(value) { endpoint.setValue = function(value) {
@ -62,7 +62,7 @@ OSM.Directions = function (map) {
delete endpoint.latlng; delete endpoint.latlng;
input.val(value); input.val(value);
endpoint.getGeocode(); endpoint.getGeocode();
} };
endpoint.getGeocode = function() { endpoint.getGeocode = function() {
// if no one has entered a value yet, then we can't geocode, so don't // if no one has entered a value yet, then we can't geocode, so don't
@ -76,7 +76,7 @@ OSM.Directions = function (map) {
$.getJSON(document.location.protocol + OSM.NOMINATIM_URL + 'search?q=' + encodeURIComponent(endpoint.value) + '&format=json', function (json) { $.getJSON(document.location.protocol + OSM.NOMINATIM_URL + 'search?q=' + encodeURIComponent(endpoint.value) + '&format=json', function (json) {
endpoint.awaitingGeocode = false; endpoint.awaitingGeocode = false;
endpoint.hasGeocode = true; endpoint.hasGeocode = true;
if (json.length == 0) { if (json.length === 0) {
alert(I18n.t('javascripts.directions.errors.no_place')); alert(I18n.t('javascripts.directions.errors.no_place'));
return; return;
} }
@ -93,7 +93,7 @@ OSM.Directions = function (map) {
getRoute(); getRoute();
} }
}); });
} };
endpoint.setLatLng = function (ll) { endpoint.setLatLng = function (ll) {
var precision = OSM.zoomPrecision(map.getZoom()); var precision = OSM.zoomPrecision(map.getZoom());
@ -137,7 +137,7 @@ OSM.Directions = function (map) {
function setEngine(id) { function setEngine(id) {
engines.forEach(function(engine, i) { engines.forEach(function(engine, i) {
if (engine.id == id) { if (engine.id === id) {
chosenEngine = engine; chosenEngine = engine;
select.val(i); select.val(i);
} }
@ -378,7 +378,7 @@ OSM.Directions = function (map) {
OSM.Directions.engines = []; OSM.Directions.engines = [];
OSM.Directions.addEngine = function (engine, supportsHTTPS) { OSM.Directions.addEngine = function (engine, supportsHTTPS) {
if (document.location.protocol == "http:" || supportsHTTPS) { if (document.location.protocol === "http:" || supportsHTTPS) {
OSM.Directions.engines.push(engine); OSM.Directions.engines.push(engine);
} }
}; };

View file

@ -19,12 +19,12 @@ function GraphHopperEngine(id, vehicleParam) {
getRoute: function (points, callback) { getRoute: function (points, callback) {
// documentation // documentation
// https://github.com/graphhopper/graphhopper/blob/master/docs/web/api-doc.md // https://github.com/graphhopper/graphhopper/blob/master/docs/web/api-doc.md
var url = document.location.protocol + "//graphhopper.com/api/1/route?" var url = document.location.protocol + "//graphhopper.com/api/1/route?" +
+ vehicleParam vehicleParam +
+ "&locale=" + I18n.currentLocale() "&locale=" + I18n.currentLocale() +
+ "&key=LijBPDQGfu7Iiq80w3HzwB4RUDJbMbhs6BU0dEnn" "&key=LijBPDQGfu7Iiq80w3HzwB4RUDJbMbhs6BU0dEnn" +
+ "&type=jsonp" "&type=jsonp" +
+ "&instructions=true"; "&instructions=true";
for (var i = 0; i < points.length; i++) { for (var i = 0; i < points.length; i++) {
url += "&point=" + points[i].lat + ',' + points[i].lng; url += "&point=" + points[i].lat + ',' + points[i].lng;
@ -34,7 +34,7 @@ function GraphHopperEngine(id, vehicleParam) {
url: url, url: url,
dataType: 'jsonp', dataType: 'jsonp',
success: function (data) { success: function (data) {
if (!data.paths || data.paths.length == 0) if (!data.paths || data.paths.length === 0)
return callback(true); return callback(true);
var path = data.paths[0]; var path = data.paths[0];
@ -70,5 +70,5 @@ function GraphHopperEngine(id, vehicleParam) {
}; };
} }
OSM.Directions.addEngine(GraphHopperEngine("graphhopper_bicycle", "vehicle=bike"), true); OSM.Directions.addEngine(new GraphHopperEngine("graphhopper_bicycle", "vehicle=bike"), true);
OSM.Directions.addEngine(GraphHopperEngine("graphhopper_foot", "vehicle=foot"), true); OSM.Directions.addEngine(new GraphHopperEngine("graphhopper_foot", "vehicle=foot"), true);

View file

@ -45,7 +45,7 @@ function MapQuestEngine(id, vehicleParam) {
$.ajax({ $.ajax({
url: url, url: url,
success: function (data) { success: function (data) {
if (data.info.statuscode != 0) if (data.info.statuscode !== 0)
return callback(true); return callback(true);
var line = []; var line = [];
@ -63,7 +63,7 @@ function MapQuestEngine(id, vehicleParam) {
var d; var d;
var linesegstart, linesegend, lineseg; var linesegstart, linesegend, lineseg;
linesegstart = data.route.shape.maneuverIndexes[i]; linesegstart = data.route.shape.maneuverIndexes[i];
if (i == mq.length - 1) { if (i === mq.length - 1) {
d = 15; d = 15;
linesegend = linesegstart + 1; linesegend = linesegstart + 1;
} else { } else {
@ -81,7 +81,7 @@ function MapQuestEngine(id, vehicleParam) {
line: line, line: line,
steps: steps, steps: steps,
distance: data.route.distance * 1000, distance: data.route.distance * 1000,
time: data.route['time'] time: data.route.time
}); });
} }
}); });
@ -89,6 +89,6 @@ function MapQuestEngine(id, vehicleParam) {
}; };
} }
OSM.Directions.addEngine(MapQuestEngine("mapquest_bicycle", "routeType=bicycle"), true); OSM.Directions.addEngine(new MapQuestEngine("mapquest_bicycle", "routeType=bicycle"), true);
OSM.Directions.addEngine(MapQuestEngine("mapquest_foot", "routeType=pedestrian"), true); OSM.Directions.addEngine(new MapQuestEngine("mapquest_foot", "routeType=pedestrian"), true);
OSM.Directions.addEngine(MapQuestEngine("mapquest_car", "routeType=fastest"), true); OSM.Directions.addEngine(new MapQuestEngine("mapquest_car", "routeType=fastest"), true);

View file

@ -48,7 +48,7 @@ function OSRMEngine() {
url: url, url: url,
dataType: 'json', dataType: 'json',
success: function (data) { success: function (data) {
if (data.status == 207) if (data.status === 207)
return callback(true); return callback(true);
previousPoints = points; previousPoints = points;
@ -68,7 +68,7 @@ function OSRMEngine() {
if (instCodes[1]) { if (instCodes[1]) {
instText += "exit " + 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'); instText += s[1] ? "<b>" + s[1] + "</b>" : I18n.t('javascripts.directions.instructions.unnamed');
} }
if ((i + 1) < data.route_instructions.length) { if ((i + 1) < data.route_instructions.length) {
@ -91,4 +91,4 @@ function OSRMEngine() {
}; };
} }
OSM.Directions.addEngine(OSRMEngine(), true); OSM.Directions.addEngine(new OSRMEngine(), true);

View file

@ -62,7 +62,7 @@ OSM.History = function(map) {
url: window.location.pathname, url: window.location.pathname,
method: "GET", method: "GET",
data: data, data: data,
success: function(html, status, xhr) { success: function(html) {
$('#sidebar_content .changesets').html(html); $('#sidebar_content .changesets').html(html);
updateMap(); updateMap();
} }

View file

@ -81,7 +81,7 @@ OSM.NewNote = function(map) {
}; };
function newHalo(loc, a) { function newHalo(loc, a) {
if (a == 'dragstart' && map.hasLayer(halo)) { if (a === 'dragstart' && map.hasLayer(halo)) {
map.removeLayer(halo); map.removeLayer(halo);
} else { } else {
if (map.hasLayer(halo)) map.removeLayer(halo); if (map.hasLayer(halo)) map.removeLayer(halo);

View file

@ -60,7 +60,7 @@ OSM.Note = function (map) {
content.find("textarea").on("input", function (e) { content.find("textarea").on("input", function (e) {
var form = e.target.form; var form = e.target.form;
if ($(e.target).val() == "") { if ($(e.target).val() === "") {
$(form.close).val(I18n.t("javascripts.notes.show.resolve")); $(form.close).val(I18n.t("javascripts.notes.show.resolve"));
$(form.comment).prop("disabled", true); $(form.comment).prop("disabled", true);
} else { } else {
@ -94,7 +94,7 @@ OSM.Note = function (map) {
map.addLayer(currentNote); map.addLayer(currentNote);
if (callback) callback(); if (callback) callback();
}; }
function moveToNote() { function moveToNote() {
var data = $('.details').data(), var data = $('.details').data(),

View file

@ -21,12 +21,12 @@ function initializeNotes(map) {
}; };
map.on("layeradd", function (e) { map.on("layeradd", function (e) {
if (e.layer == noteLayer) { if (e.layer === noteLayer) {
loadNotes(); loadNotes();
map.on("moveend", loadNotes); map.on("moveend", loadNotes);
} }
}).on("layerremove", function (e) { }).on("layerremove", function (e) {
if (e.layer == noteLayer) { if (e.layer === noteLayer) {
map.off("moveend", loadNotes); map.off("moveend", loadNotes);
noteLayer.clearLayers(); noteLayer.clearLayers();
notes = {}; notes = {};

View file

@ -24,13 +24,13 @@ OSM.Query = function(map) {
} else if (!queryButton.hasClass("disabled")) { } else if (!queryButton.hasClass("disabled")) {
enableQueryMode(); enableQueryMode();
} }
}).on("disabled", function (e) { }).on("disabled", function () {
if (queryButton.hasClass("active")) { if (queryButton.hasClass("active")) {
map.off("click", clickHandler); map.off("click", clickHandler);
$(map.getContainer()).removeClass("query-active").addClass("query-disabled"); $(map.getContainer()).removeClass("query-active").addClass("query-disabled");
$(this).tooltip("show"); $(this).tooltip("show");
} }
}).on("enabled", function (e) { }).on("enabled", function () {
if (queryButton.hasClass("active")) { if (queryButton.hasClass("active")) {
map.on("click", clickHandler); map.on("click", clickHandler);
$(map.getContainer()).removeClass("query-disabled").addClass("query-active"); $(map.getContainer()).removeClass("query-disabled").addClass("query-active");
@ -40,20 +40,20 @@ OSM.Query = function(map) {
$("#sidebar_content") $("#sidebar_content")
.on("mouseover", ".query-results li.query-result", function () { .on("mouseover", ".query-results li.query-result", function () {
var geometry = $(this).data("geometry") var geometry = $(this).data("geometry");
if (geometry) map.addLayer(geometry); if (geometry) map.addLayer(geometry);
$(this).addClass("selected"); $(this).addClass("selected");
}) })
.on("mouseout", ".query-results li.query-result", function () { .on("mouseout", ".query-results li.query-result", function () {
var geometry = $(this).data("geometry") var geometry = $(this).data("geometry");
if (geometry) map.removeLayer(geometry); if (geometry) map.removeLayer(geometry);
$(this).removeClass("selected"); $(this).removeClass("selected");
}) })
.on("mousedown", ".query-results li.query-result", function (e) { .on("mousedown", ".query-results li.query-result", function () {
var moved = false; var moved = false;
$(this).one("click", function (e) { $(this).one("click", function (e) {
if (!moved) { if (!moved) {
var geometry = $(this).data("geometry") var geometry = $(this).data("geometry");
if (geometry) map.removeLayer(geometry); if (geometry) map.removeLayer(geometry);
if (!$(e.target).is('a')) { if (!$(e.target).is('a')) {
@ -65,7 +65,7 @@ OSM.Query = function(map) {
}); });
}); });
function interestingFeature(feature, origin, radius) { function interestingFeature(feature) {
if (feature.tags) { if (feature.tags) {
for (var key in feature.tags) { for (var key in feature.tags) {
if (uninterestingTags.indexOf(key) < 0) { if (uninterestingTags.indexOf(key) < 0) {
@ -82,10 +82,9 @@ OSM.Query = function(map) {
var prefix = ""; var prefix = "";
if (tags.boundary === "administrative" && tags.admin_level) { if (tags.boundary === "administrative" && tags.admin_level) {
prefix = prefix = I18n.t("geocoder.search_osm_nominatim.admin_levels.level" + tags.admin_level, {
I18n.t("geocoder.search_osm_nominatim.admin_levels.level" + tags.admin_level, {
defaultValue: I18n.t("geocoder.search_osm_nominatim.prefix.boundary.administrative") defaultValue: I18n.t("geocoder.search_osm_nominatim.prefix.boundary.administrative")
}) });
} else { } else {
var prefixes = I18n.t("geocoder.search_osm_nominatim.prefix"); var prefixes = I18n.t("geocoder.search_osm_nominatim.prefix");
@ -128,10 +127,10 @@ OSM.Query = function(map) {
} }
} }
if (tags["name"]) { if (tags.name) {
return tags["name"]; return tags.name;
} else if (tags["ref"]) { } else if (tags.ref) {
return tags["ref"]; return tags.ref;
} else if (tags["addr:housename"]) { } else if (tags["addr:housename"]) {
return tags["addr:housename"]; return tags["addr:housename"];
} else if (tags["addr:housenumber"] && tags["addr:street"]) { } else if (tags["addr:housenumber"] && tags["addr:street"]) {
@ -195,7 +194,7 @@ OSM.Query = function(map) {
for (var i = 0; i < elements.length; i++) { for (var i = 0; i < elements.length; i++) {
var element = elements[i]; var element = elements[i];
if (interestingFeature(element, latlng, radius)) { if (interestingFeature(element)) {
var $li = $("<li>") var $li = $("<li>")
.addClass("query-result") .addClass("query-result")
.data("geometry", featureGeometry(element)) .data("geometry", featureGeometry(element))
@ -211,7 +210,7 @@ OSM.Query = function(map) {
} }
} }
if ($ul.find("li").length == 0) { if ($ul.find("li").length === 0) {
$("<li>") $("<li>")
.text(I18n.t("javascripts.query.nothing_found")) .text(I18n.t("javascripts.query.nothing_found"))
.appendTo($ul); .appendTo($ul);
@ -277,7 +276,7 @@ OSM.Query = function(map) {
marker = L.circle(latlng, radius, featureStyle).addTo(map); marker = L.circle(latlng, radius, featureStyle).addTo(map);
$(document).everyTime(75, "fadeQueryMarker", function (i) { $(document).everyTime(75, "fadeQueryMarker", function (i) {
if (i == 10) { if (i === 10) {
map.removeLayer(marker); map.removeLayer(marker);
} else { } else {
marker.setStyle({ marker.setStyle({

View file

@ -2,7 +2,7 @@
OSM.Search = function(map) { OSM.Search = function(map) {
$(".search_form input[name=query]").on("input", function(e) { $(".search_form input[name=query]").on("input", function(e) {
if ($(e.target).val() == "") { if ($(e.target).val() === "") {
$(".describe_location").fadeIn(100); $(".describe_location").fadeIn(100);
} else { } else {
$(".describe_location").fadeOut(100); $(".describe_location").fadeOut(100);
@ -68,7 +68,7 @@ OSM.Search = function(map) {
}); });
} }
function showSearchResult(e) { function showSearchResult() {
var marker = $(this).data("marker"); var marker = $(this).data("marker");
if (!marker) { if (!marker) {
@ -84,7 +84,7 @@ OSM.Search = function(map) {
$(this).closest("li").addClass("selected"); $(this).closest("li").addClass("selected");
} }
function hideSearchResult(e) { function hideSearchResult() {
var marker = $(this).data("marker"); var marker = $(this).data("marker");
if (marker) { if (marker) {

View file

@ -60,12 +60,13 @@ L.OSM.key = function (options) {
} }
function updateButton() { function updateButton() {
var disabled = map.getMapBaseLayerId() !== 'mapnik' var disabled = map.getMapBaseLayerId() !== 'mapnik';
button button
.toggleClass('disabled', disabled) .toggleClass('disabled', disabled)
.attr('data-original-title', I18n.t(disabled ? .attr('data-original-title',
'javascripts.key.tooltip_disabled' : I18n.t(disabled ?
'javascripts.key.tooltip')) 'javascripts.key.tooltip_disabled' :
'javascripts.key.tooltip'));
} }
function update() { function update() {
@ -74,7 +75,7 @@ L.OSM.key = function (options) {
$('.mapkey-table-entry').each(function () { $('.mapkey-table-entry').each(function () {
var data = $(this).data(); 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(); $(this).show();
} else { } else {
$(this).hide(); $(this).hide();

View file

@ -107,7 +107,7 @@ L.OSM.layers = function(options) {
}); });
}); });
if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') { if (OSM.STATUS !== 'api_offline' && OSM.STATUS !== 'database_offline') {
var overlaySection = $('<div>') var overlaySection = $('<div>')
.attr('class', 'section overlay-layers') .attr('class', 'section overlay-layers')
.appendTo($ui); .appendTo($ui);
@ -120,7 +120,7 @@ L.OSM.layers = function(options) {
var list = $('<ul>') var list = $('<ul>')
.appendTo(overlaySection); .appendTo(overlaySection);
function addOverlay(layer, name, maxArea) { var addOverlay = function (layer, name, maxArea) {
var item = $('<li>') var item = $('<li>')
.tooltip({ .tooltip({
placement: 'top' placement: 'top'
@ -170,7 +170,7 @@ L.OSM.layers = function(options) {
item.attr('data-original-title', disabled ? item.attr('data-original-title', disabled ?
I18n.t('javascripts.site.map_' + name + '_zoom_in_tooltip') : ''); I18n.t('javascripts.site.map_' + name + '_zoom_in_tooltip') : '');
}); });
} };
addOverlay(map.noteLayer, 'notes', OSM.MAX_NOTE_REQUEST_AREA); addOverlay(map.noteLayer, 'notes', OSM.MAX_NOTE_REQUEST_AREA);
addOverlay(map.dataLayer, 'data', OSM.MAX_REQUEST_AREA); addOverlay(map.dataLayer, 'data', OSM.MAX_REQUEST_AREA);

View file

@ -64,7 +64,7 @@ L.OSM.Map = L.Map.extend({
if (layerParam.indexOf(this.baseLayers[i].options.code) >= 0) { if (layerParam.indexOf(this.baseLayers[i].options.code) >= 0) {
this.addLayer(this.baseLayers[i]); this.addLayer(this.baseLayers[i]);
layersAdded = layersAdded + this.baseLayers[i].options.code; layersAdded = layersAdded + this.baseLayers[i].options.code;
} else if (i == 0 && layersAdded == "") { } else if (i === 0 && layersAdded === "") {
this.addLayer(this.baseLayers[i]); this.addLayer(this.baseLayers[i]);
} else { } else {
this.removeLayer(this.baseLayers[i]); this.removeLayer(this.baseLayers[i]);
@ -210,7 +210,7 @@ L.OSM.Map = L.Map.extend({
return true; return true;
} else if (object.type === "relation") { } else if (object.type === "relation") {
for (var i = 0; i < relations.length; i++) for (var i = 0; i < relations.length; i++)
if (relations[i].members.indexOf(node) != -1) if (relations[i].members.indexOf(node) !== -1)
return true; return true;
} else { } else {
return false; return false;
@ -236,7 +236,7 @@ L.OSM.Map = L.Map.extend({
center: this.getCenter().wrap(), center: this.getCenter().wrap(),
zoom: this.getZoom(), zoom: this.getZoom(),
layers: this.getLayersCode() layers: this.getLayersCode()
} };
}, },
setState: function(state, options) { setState: function(state, options) {

View file

@ -13,8 +13,6 @@ L.OSM.note = function (options) {
map.on('zoomend', update); map.on('zoomend', update);
update();
function update() { function update() {
var disabled = OSM.STATUS === "database_offline" || map.getZoom() < 12; var disabled = OSM.STATUS === "database_offline" || map.getZoom() < 12;
link link
@ -24,6 +22,8 @@ L.OSM.note = function (options) {
'javascripts.site.createnote_tooltip')); 'javascripts.site.createnote_tooltip'));
} }
update();
return $container[0]; return $container[0];
}; };

View file

@ -44,7 +44,7 @@ $(document).ready(function () {
var width = editor.outerWidth() - preview.outerWidth() + preview.width(); var width = editor.outerWidth() - preview.outerWidth() + preview.width();
var minHeight = editor.outerHeight() - preview.outerHeight() + preview.height(); var minHeight = editor.outerHeight() - preview.outerHeight() + preview.height();
if (preview.contents().length == 0) { if (preview.contents().length === 0) {
preview.oneTime(500, "loading", function () { preview.oneTime(500, "loading", function () {
preview.addClass("loading"); preview.addClass("loading");
}); });

View file

@ -86,7 +86,7 @@ OSM.Router = function(map, rts) {
var routes = []; var routes = [];
for (var r in rts) for (var r in rts)
routes.push(Route(r, rts[r])); routes.push(new Route(r, rts[r]));
routes.recognize = function(path) { routes.recognize = function(path) {
for (var i = 0; i < this.length; i++) { for (var i = 0; i < this.length; i++) {

View file

@ -17,13 +17,13 @@ $(document).ready(function() {
$('.start-mapping').attr('href', url); $('.start-mapping').attr('href', url);
} else { } else {
function geoSuccess(position) { var geoSuccess = function (position) {
window.location = '/edit' + OSM.formatHash({ window.location = '/edit' + OSM.formatHash({
zoom: 17, zoom: 17,
lat: position.coords.latitude, lat: position.coords.latitude,
lon: position.coords.longitude lon: position.coords.longitude
}); });
} };
$('.start-mapping').on('click', function(e) { $('.start-mapping').on('click', function(e) {
e.preventDefault(); e.preventDefault();

View file

@ -17,16 +17,16 @@ var trim = require('trim');
*/ */
exports.parse = function(str){ exports.parse = function(str){
if ('string' != typeof str) return {}; if ('string' !== typeof str) return {};
str = trim(str); str = trim(str);
if ('' == str) return {}; if ('' === str) return {};
var obj = {}; var obj = {};
var pairs = str.split('&'); var pairs = str.split('&');
for (var i = 0; i < pairs.length; i++) { for (var i = 0; i < pairs.length; i++) {
var parts = pairs[i].split('='); var parts = pairs[i].split('=');
obj[parts[0]] = null == parts[1] obj[parts[0]] = null === parts[1]
? '' ? ''
: decodeURIComponent(parts[1]); : decodeURIComponent(parts[1]);
} }
@ -68,4 +68,4 @@ exports.right = function(str){
}; };
},{}]},{},[]) },{}]},{},[])
; ;