Enable a number of eslint style rules

This commit is contained in:
Tom Hughes 2019-04-07 17:02:39 +01:00
parent 8030e7b5d6
commit 5bd59e1936
28 changed files with 278 additions and 240 deletions

View file

@ -24,7 +24,7 @@ var querystring = require("querystring-component");
* view tab and various other links
*/
window.updateLinks = function (loc, zoom, layers, object) {
$(".geolink").each(function(index, link) {
$(".geolink").each(function (index, link) {
var href = link.href.split(/[?#]/)[0],
args = querystring.parse(link.search.substring(1)),
editlink = $(link).hasClass("editlink");
@ -58,9 +58,9 @@ window.updateLinks = function (loc, zoom, layers, object) {
var editDisabled = zoom < 13;
$("#edit_tab")
.tooltip({placement: "bottom"})
.tooltip({ placement: "bottom" })
.off("click.minzoom")
.on("click.minzoom", function() { return !editDisabled; })
.on("click.minzoom", function () { return !editDisabled; })
.toggleClass("disabled", editDisabled)
.attr("data-original-title", editDisabled ?
I18n.t("javascripts.site.edit_disabled_tooltip") : "");
@ -97,13 +97,13 @@ $(document).ready(function () {
* to defer the measurement slightly as a workaround.
*/
setTimeout(function () {
$("header").children(":visible").each(function (i,e) {
$("header").children(":visible").each(function (i, e) {
headerWidth = headerWidth + $(e).outerWidth();
});
$("body").addClass("compact");
$("header").children(":visible").each(function (i,e) {
$("header").children(":visible").each(function (i, e) {
compactWidth = compactWidth + $(e).outerWidth();
});
@ -114,12 +114,12 @@ $(document).ready(function () {
$(window).resize(updateHeader);
}, 0);
$("#menu-icon").on("click", function(e) {
$("#menu-icon").on("click", function (e) {
e.preventDefault();
$("header").toggleClass("closed");
});
$("nav.primary li a").on("click", function() {
$("nav.primary li a").on("click", function () {
$("header").toggleClass("closed");
});

View file

@ -9,7 +9,7 @@ $(document).ready(function () {
map.removeLayer(marker);
}
marker = L.marker(e.latlng, {icon: OSM.getUserIcon()}).addTo(map)
marker = L.marker(e.latlng, { icon: OSM.getUserIcon() }).addTo(map)
.bindPopup(I18n.t("diary_entries.edit.marker_text"));
}
@ -28,13 +28,13 @@ $(document).ready(function () {
zoomControl: false
}).addLayer(new L.OSM.Mapnik());
L.OSM.zoom({position: position})
L.OSM.zoom({ position: position })
.addTo(map);
map.setView(centre, params.zoom);
if ($("#latitude").val() && $("#longitude").val()) {
marker = L.marker(centre, {icon: OSM.getUserIcon()}).addTo(map)
marker = L.marker(centre, { icon: OSM.getUserIcon() }).addTo(map)
.bindPopup(I18n.t("diary_entries.edit.marker_text"));
}

View file

@ -1,4 +1,4 @@
$(document).ready(function() {
$(document).ready(function () {
var params = OSM.params();
var url = "/note/new";

View file

@ -2,7 +2,7 @@
/* globals iD */
document.addEventListener("DOMContentLoaded", function() {
document.addEventListener("DOMContentLoaded", function () {
var container = document.getElementById("id-container");
if (typeof iD === "undefined" || !iD.Detect().support) {
@ -24,7 +24,7 @@ document.addEventListener("DOMContentLoaded", function() {
oauth_token_secret: container.dataset.tokenSecret
});
id.map().on("move.embed", parent.$.throttle(250, function() {
id.map().on("move.embed", parent.$.throttle(250, function () {
if (id.inIntro()) return;
var zoom = ~~id.map().zoom(),
center = id.map().center(),
@ -46,7 +46,7 @@ document.addEventListener("DOMContentLoaded", function() {
// 0ms timeout to avoid iframe JS context weirdness.
// http://bl.ocks.org/jfirebaugh/5439412
setTimeout(function() {
setTimeout(function () {
id.map().centerZoom(
[data.lon, data.lat],
Math.max(data.zoom || 15, 13));

View file

@ -31,12 +31,12 @@ $(document).ready(function () {
contextmenu: true
});
OSM.loadSidebarContent = function(path, callback) {
OSM.loadSidebarContent = function (path, callback) {
map.setSidebarOverlaid(false);
clearTimeout(loaderTimeout);
loaderTimeout = setTimeout(function() {
loaderTimeout = setTimeout(function () {
$("#sidebar_loader").show();
}, 200);
@ -54,7 +54,7 @@ $(document).ready(function () {
$.ajax({
url: path,
dataType: "html",
complete: function(xhr) {
complete: function (xhr) {
clearTimeout(loaderTimeout);
$("#flash").empty();
$("#sidebar_loader").hide();
@ -96,7 +96,7 @@ $(document).ready(function () {
var position = $("html").attr("dir") === "rtl" ? "topleft" : "topright";
L.OSM.zoom({position: position})
L.OSM.zoom({ position: position })
.addTo(map);
var locate = L.control.locate({
@ -134,9 +134,9 @@ $(document).ready(function () {
}).addTo(map);
L.OSM.share({
position: position,
sidebar: sidebar,
short: true
"position": position,
"sidebar": sidebar,
"short": true
}).addTo(map);
L.OSM.note({
@ -171,12 +171,12 @@ $(document).ready(function () {
}
var placement = $("html").attr("dir") === "rtl" ? "right" : "left";
$(".leaflet-control .control-button").tooltip({placement: placement, container: "body"});
$(".leaflet-control .control-button").tooltip({ placement: placement, container: "body" });
var expiry = new Date();
expiry.setYear(expiry.getFullYear() + 10);
map.on("moveend layeradd layerremove", function() {
map.on("moveend layeradd layerremove", function () {
updateLinks(
map.getCenter().wrap(),
map.getZoom(),
@ -191,7 +191,7 @@ $(document).ready(function () {
$(".welcome").addClass("visible");
}
$(".welcome .close-wrap").on("click", function() {
$(".welcome .close-wrap").on("click", function () {
$(".welcome").removeClass("visible");
$.cookie("_osm_welcome", "hide", { expires: expiry, path: "/" });
});
@ -199,7 +199,7 @@ $(document).ready(function () {
var bannerExpiry = new Date();
bannerExpiry.setYear(bannerExpiry.getFullYear() + 1);
$("#banner .close-wrap").on("click", function(e) {
$("#banner .close-wrap").on("click", function (e) {
var cookieId = e.target.id;
$("#banner").hide();
e.preventDefault();
@ -230,14 +230,14 @@ $(document).ready(function () {
L.marker([params.mlat, params.mlon]).addTo(map);
}
$("#homeanchor").on("click", function(e) {
$("#homeanchor").on("click", function (e) {
e.preventDefault();
var data = $(this).data(),
center = L.latLng(data.lat, data.lon);
map.setView(center, data.zoom);
L.marker(center, {icon: OSM.getUserIcon()}).addTo(map);
L.marker(center, { icon: OSM.getUserIcon() }).addTo(map);
});
function remoteEditHandler(bbox, object) {
@ -251,7 +251,7 @@ $(document).ready(function () {
};
if (location.protocol === "http" ||
bowser.check({chrome: "53", firefox: "55"})) {
bowser.check({ chrome: "53", firefox: "55" })) {
url = "http://127.0.0.1:8111/load_and_zoom?";
} else {
url = "https://127.0.0.1:8112/load_and_zoom?";
@ -263,7 +263,7 @@ $(document).ready(function () {
.hide()
.appendTo("body")
.attr("src", url + querystring.stringify(query))
.on("load", function() {
.on("load", function () {
$(this).remove();
loaded = true;
});
@ -278,7 +278,7 @@ $(document).ready(function () {
return false;
}
$("a[data-editor=remote]").click(function(e) {
$("a[data-editor=remote]").click(function (e) {
var params = OSM.mapParams(this.search);
remoteEditHandler(map.getBounds(), params.object);
e.preventDefault();
@ -293,20 +293,20 @@ $(document).ready(function () {
})
.tooltip("show");
$("body").one("click", function() {
$("body").one("click", function () {
$("#editanchor").tooltip("hide");
});
}
OSM.Index = function(map) {
OSM.Index = function (map) {
var page = {};
page.pushstate = page.popstate = function() {
page.pushstate = page.popstate = function () {
map.setSidebarOverlaid(true);
document.title = I18n.t("layouts.project_name.title");
};
page.load = function() {
page.load = function () {
var params = querystring.parse(location.search.substring(1));
if (params.query) {
$("#sidebar .search_form input[name=query]").value(params.query);
@ -320,21 +320,21 @@ $(document).ready(function () {
return page;
};
OSM.Browse = function(map, type) {
OSM.Browse = function (map, type) {
var page = {};
page.pushstate = page.popstate = function(path, id) {
OSM.loadSidebarContent(path, function() {
page.pushstate = page.popstate = function (path, id) {
OSM.loadSidebarContent(path, function () {
addObject(type, id);
});
};
page.load = function(path, id) {
page.load = function (path, id) {
addObject(type, id, true);
};
function addObject(type, id, center) {
map.addObject({type: type, id: parseInt(id, 10)}, function(bounds) {
map.addObject({ type: type, id: parseInt(id, 10) }, function (bounds) {
if (!window.location.hash && bounds.isValid() &&
(center || !map.getBounds().contains(bounds))) {
OSM.router.withoutMoveListener(function () {
@ -344,7 +344,7 @@ $(document).ready(function () {
});
}
page.unload = function() {
page.unload = function () {
map.removeObject();
};
@ -354,21 +354,21 @@ $(document).ready(function () {
var history = OSM.History(map);
OSM.router = OSM.Router(map, {
"/": OSM.Index(map),
"/search": OSM.Search(map),
"/directions": OSM.Directions(map),
"/export": OSM.Export(map),
"/note/new": OSM.NewNote(map),
"/history/friends": history,
"/history/nearby": history,
"/history": history,
"/": OSM.Index(map),
"/search": OSM.Search(map),
"/directions": OSM.Directions(map),
"/export": OSM.Export(map),
"/note/new": OSM.NewNote(map),
"/history/friends": history,
"/history/nearby": history,
"/history": history,
"/user/:display_name/history": history,
"/note/:id": OSM.Note(map),
"/node/:id(/history)": OSM.Browse(map, "node"),
"/way/:id(/history)": OSM.Browse(map, "way"),
"/relation/:id(/history)": OSM.Browse(map, "relation"),
"/changeset/:id": OSM.Changeset(map),
"/query": OSM.Query(map)
"/note/:id": OSM.Note(map),
"/node/:id(/history)": OSM.Browse(map, "node"),
"/way/:id(/history)": OSM.Browse(map, "way"),
"/relation/:id(/history)": OSM.Browse(map, "relation"),
"/changeset/:id": OSM.Changeset(map),
"/query": OSM.Query(map)
});
if (OSM.preferred_editor === "remote" && document.location.pathname === "/edit") {
@ -378,19 +378,23 @@ $(document).ready(function () {
OSM.router.load();
$(document).on("click", "a", function(e) {
if (e.isDefaultPrevented() || e.isPropagationStopped())
$(document).on("click", "a", function (e) {
if (e.isDefaultPrevented() || e.isPropagationStopped()) {
return;
}
// Open links in a new tab as normal.
if (e.which > 1 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey)
if (e.which > 1 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) {
return;
}
// Ignore cross-protocol and cross-origin links.
if (location.protocol !== this.protocol || location.host !== this.host)
if (location.protocol !== this.protocol || location.host !== this.host) {
return;
}
if (OSM.router.route(this.pathname + this.search + this.hash))
if (OSM.router.route(this.pathname + this.search + this.hash)) {
e.preventDefault();
}
});
});

View file

@ -120,7 +120,7 @@ OSM.initializeBrowse = function (map) {
// Redraw in selected style
layer.originalStyle = layer.options;
layer.setStyle({color: "#0000ff", weight: 8});
layer.setStyle({ color: "#0000ff", weight: 8 });
OSM.router.route("/" + layer.feature.type + "/" + layer.feature.id);

View file

@ -3,21 +3,20 @@ OSM.Changeset = function (map) {
content = $("#sidebar_content"),
currentChangesetId;
page.pushstate = page.popstate = function(path, id) {
OSM.loadSidebarContent(path, function() {
page.pushstate = page.popstate = function (path, id) {
OSM.loadSidebarContent(path, function () {
page.load(path, id);
});
};
page.load = function(path, id) {
if (id)
currentChangesetId = id;
page.load = function (path, id) {
if (id) currentChangesetId = id;
initialize();
addChangeset(currentChangesetId, true);
};
function addChangeset(id, center) {
map.addObject({type: "changeset", id: parseInt(id, 10)}, function(bounds) {
map.addObject({ type: "changeset", id: parseInt(id, 10) }, function (bounds) {
if (!window.location.hash && bounds.isValid() &&
(center || !map.getBounds().contains(bounds))) {
OSM.router.withoutMoveListener(function () {
@ -33,7 +32,7 @@ OSM.Changeset = function (map) {
$(form).find("input[type=submit]").prop("disabled", true);
if (include_data) {
data = {text: $(form.text).val()};
data = { text: $(form.text).val() };
} else {
data = {};
}
@ -75,7 +74,7 @@ OSM.Changeset = function (map) {
content.find("textarea").val("").trigger("input");
}
page.unload = function() {
page.unload = function () {
map.removeObject();
};

View file

@ -77,7 +77,7 @@ OSM.initializeContextMenu = function (map) {
else map.contextmenu.enable();
});
var updateMenu = function updateMenu () {
var updateMenu = function updateMenu() {
map.contextmenu.setDisabled(2, map.getZoom() < 12);
map.contextmenu.setDisabled(4, map.getZoom() < 14);
};

View file

@ -6,7 +6,7 @@ OSM.Directions = function (map) {
var awaitingRoute; // true if we've asked the engine for a route and are waiting to hear back
var chosenEngine;
var popup = L.popup({autoPanPadding: [100, 100]});
var popup = L.popup({ autoPanPadding: [100, 100] });
var polyline = L.polyline([], {
color: "#03f",
@ -38,7 +38,7 @@ OSM.Directions = function (map) {
var select = $("select.routing_engines");
engines.forEach(function(engine, i) {
engines.forEach(function (engine, i) {
select.append("<option value='" + i + "'>" + I18n.t("javascripts.directions.engines." + engine.id) + "</option>");
});
@ -68,7 +68,7 @@ OSM.Directions = function (map) {
}
});
input.on("keydown", function() {
input.on("keydown", function () {
input.removeClass("error");
});
@ -80,7 +80,7 @@ OSM.Directions = function (map) {
endpoint.setValue(value);
});
endpoint.setValue = function(value, latlng) {
endpoint.setValue = function (value, latlng) {
endpoint.value = value;
delete endpoint.latlng;
input.removeClass("error");
@ -93,7 +93,7 @@ OSM.Directions = function (map) {
}
};
endpoint.getGeocode = function() {
endpoint.getGeocode = function () {
// if no one has entered a value yet, then we can't geocode, so don't
// even try.
if (!endpoint.value) {
@ -107,7 +107,7 @@ OSM.Directions = function (map) {
endpoint.hasGeocode = true;
if (json.length === 0) {
input.addClass("error");
alert(I18n.t("javascripts.directions.errors.no_place", {place: endpoint.value}));
alert(I18n.t("javascripts.directions.errors.no_place", { place: endpoint.value }));
return;
}
@ -135,7 +135,7 @@ OSM.Directions = function (map) {
return endpoint;
}
$(".directions_form .reverse_directions").on("click", function() {
$(".directions_form .reverse_directions").on("click", function () {
var from = endpoints[0].latlng,
to = endpoints[1].latlng;
@ -146,7 +146,7 @@ OSM.Directions = function (map) {
}));
});
$(".directions_form .close").on("click", function(e) {
$(".directions_form .close").on("click", function (e) {
e.preventDefault();
var route_from = endpoints[0].value;
if (route_from) {
@ -174,7 +174,7 @@ OSM.Directions = function (map) {
}
function findEngine(id) {
return engines.findIndex(function(engine) {
return engines.findIndex(function (engine) {
return engine.id === id;
});
}
@ -251,7 +251,7 @@ OSM.Directions = function (map) {
if (typeof route.ascend !== "undefined" && typeof route.descend !== "undefined") {
html += "<br />" +
I18n.t("javascripts.directions.ascend") + ": " + Math.round(route.ascend) + "m. " +
I18n.t("javascripts.directions.descend") + ": " + Math.round(route.descend) +"m.";
I18n.t("javascripts.directions.descend") + ": " + Math.round(route.descend) + "m.";
}
html += "</p><table id=\"turnbyturn\" />";
@ -269,13 +269,13 @@ OSM.Directions = function (map) {
if (dist < 5) {
dist = "";
} else if (dist < 200) {
dist = Math.round(dist / 10) * 10 + "m";
dist = String(Math.round(dist / 10) * 10) + "m";
} else if (dist < 1500) {
dist = Math.round(dist / 100) * 100 + "m";
dist = String(Math.round(dist / 100) * 100) + "m";
} else if (dist < 5000) {
dist = Math.round(dist / 100) / 10 + "km";
dist = String(Math.round(dist / 100) / 10) + "km";
} else {
dist = Math.round(dist / 1000) + "km";
dist = String(Math.round(dist / 1000)) + "km";
}
var row = $("<tr class='turn'/>");
@ -302,10 +302,10 @@ OSM.Directions = function (map) {
});
$("#sidebar_content").append("<p id=\"routing_credit\">" +
I18n.t("javascripts.directions.instructions.courtesy", {link: chosenEngine.creditline}) +
I18n.t("javascripts.directions.instructions.courtesy", { link: chosenEngine.creditline }) +
"</p>");
$("#sidebar_content a.geolink").on("click", function(e) {
$("#sidebar_content a.geolink").on("click", function (e) {
e.preventDefault();
map.removeLayer(polyline);
$("#sidebar_content").html("");
@ -329,7 +329,7 @@ OSM.Directions = function (map) {
}
});
$(".directions_form").on("submit", function(e) {
$(".directions_form").on("submit", function (e) {
e.preventDefault();
getRoute(true, true);
});
@ -347,7 +347,7 @@ OSM.Directions = function (map) {
var page = {};
page.pushstate = page.popstate = function() {
page.pushstate = page.popstate = function () {
$(".search_form").hide();
$(".directions_form").show();
@ -388,11 +388,11 @@ OSM.Directions = function (map) {
getRoute(true, true);
};
page.load = function() {
page.load = function () {
page.pushstate();
};
page.unload = function() {
page.unload = function () {
$(".search_form").show();
$(".directions_form").hide();
$("#map").off("dragend dragover drop");

View file

@ -9,7 +9,7 @@ function FOSSGISEngine(id, vehicleType) {
creditline: "<a href=\"https://routing.openstreetmap.de/about.html\" target=\"_blank\">FOSSGIS Routing Service</a>",
draggable: true,
_transformSteps: function(input_steps, line) {
_transformSteps: function (input_steps, line) {
var INSTRUCTION_TEMPLATE = {
"continue": "javascripts.directions.instructions.continue",
"merge right": "javascripts.directions.instructions.merge_right",
@ -35,7 +35,7 @@ function FOSSGISEngine(id, vehicleType) {
"exit roundabout": "javascripts.directions.instructions.exit_roundabout",
"exit rotary": "javascripts.directions.instructions.exit_roundabout",
"depart": "javascripts.directions.instructions.start",
"arrive": "javascripts.directions.instructions.destination",
"arrive": "javascripts.directions.instructions.destination"
};
var ICON_MAP = {
"continue": 0,
@ -64,10 +64,10 @@ function FOSSGISEngine(id, vehicleType) {
"depart": 8,
"arrive": 14
};
var numToWord = function(num) {
return ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth"][num-1];
var numToWord = function (num) {
return ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth"][num - 1];
};
var transformed_steps = input_steps.map(function(step, idx) {
var transformed_steps = input_steps.map(function (step, idx) {
var maneuver_id;
// special case handling
@ -99,7 +99,7 @@ function FOSSGISEngine(id, vehicleType) {
var template = INSTRUCTION_TEMPLATE[maneuver_id];
// convert lat,lng pairs to LatLng objects
var step_geometry = L.PolylineUtil.decode(step.geometry, { precision: 5 }).map(function(a) { return L.latLng(a); });
var step_geometry = L.PolylineUtil.decode(step.geometry, { precision: 5 }).map(function (a) { return L.latLng(a); });
// append step_geometry on line
Array.prototype.push.apply(line, step_geometry);
@ -150,7 +150,6 @@ function FOSSGISEngine(id, vehicleType) {
},
getRoute: function (points, callback) {
var params = [
{ name: "overview", value: "false" },
{ name: "geometries", value: "polyline" },
@ -159,23 +158,24 @@ function FOSSGISEngine(id, vehicleType) {
if (cachedHints.length === points.length) {
params.push({name: "hints", value: cachedHints.join(";")});
params.push({ name: "hints", value: cachedHints.join(";") });
} else {
// invalidate cache
cachedHints = [];
}
var encoded_coords = points.map(function(p) {
var encoded_coords = points.map(function (p) {
return p.lng + "," + p.lat;
}).join(";");
var req_url = OSM.FOSSGIS_OSRM_URL + "routed-" + vehicleType + "/route/v1/driving/" + encoded_coords;
var onResponse = function (data) {
if (data.code !== "Ok")
if (data.code !== "Ok") {
return callback(true);
}
cachedHints = data.waypoints.map(function(wp) {
cachedHints = data.waypoints.map(function (wp) {
return wp.hint;
});

View file

@ -3,13 +3,13 @@ function GraphHopperEngine(id, vehicleType) {
"-3": 7, // sharp left
"-2": 6, // left
"-1": 5, // slight left
0: 0, // straight
1: 1, // slight right
2: 2, // right
3: 3, // sharp right
4: 14, // finish reached
5: 14, // via reached
6: 10 // roundabout
"0": 0, // straight
"1": 1, // slight right
"2": 2, // right
"3": 3, // sharp right
"4": 14, // finish reached
"5": 14, // via reached
"6": 10 // roundabout
};
return {
@ -23,19 +23,20 @@ function GraphHopperEngine(id, vehicleType) {
return $.ajax({
url: OSM.GRAPHHOPPER_URL,
data: {
vehicle: vehicleType,
locale: I18n.currentLocale(),
key: "LijBPDQGfu7Iiq80w3HzwB4RUDJbMbhs6BU0dEnn",
"vehicle": vehicleType,
"locale": I18n.currentLocale(),
"key": "LijBPDQGfu7Iiq80w3HzwB4RUDJbMbhs6BU0dEnn",
"ch.disable": vehicleType === "car",
elevation: false,
instructions: true,
point: points.map(function (p) { return p.lat + "," + p.lng; })
"elevation": false,
"instructions": true,
"point": points.map(function (p) { return p.lat + "," + p.lng; })
},
traditional: true,
dataType: "json",
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];
var line = L.PolylineUtil.decode(path.points);
@ -51,10 +52,10 @@ function GraphHopperEngine(id, vehicleType) {
var distInMeter = instr.distance;
var lineseg = [];
for (var j = instr.interval[0]; j <= instr.interval[1]; j++) {
lineseg.push({lat: line[j][0], lng: line[j][1]});
lineseg.push({ lat: line[j][0], lng: line[j][1] });
}
steps.push([
{lat: latLng[0], lng: latLng[1]},
{ lat: latLng[0], lng: latLng[1] },
instrCode,
instrText,
distInMeter,

View file

@ -1,4 +1,4 @@
OSM.Export = function(map) {
OSM.Export = function (map) {
var page = {};
var locationFilter = new L.LocationFilter({
@ -57,12 +57,12 @@ OSM.Export = function(map) {
if (getBounds().getSize() > OSM.MAX_REQUEST_AREA) e.preventDefault();
}
page.pushstate = page.popstate = function(path) {
page.pushstate = page.popstate = function (path) {
$("#export_tab").addClass("current");
OSM.loadSidebarContent(path, page.load);
};
page.load = function() {
page.load = function () {
map
.addLayer(locationFilter)
.on("moveend", update);
@ -75,7 +75,7 @@ OSM.Export = function(map) {
return map.getState();
};
page.unload = function() {
page.unload = function () {
map
.removeLayer(locationFilter)
.off("moveend", update);

View file

@ -1,6 +1,6 @@
//= require jquery.simulate
OSM.History = function(map) {
OSM.History = function (map) {
var page = {};
$("#sidebar_content")
@ -13,13 +13,15 @@ OSM.History = function(map) {
})
.on("mousedown", "[data-changeset]", function () {
var moved = false;
$(this).one("click", function (e) {
if (!moved && !$(e.target).is("a")) {
clickChangeset($(this).data("changeset").id, e);
}
}).one("mousemove", function () {
moved = true;
});
$(this)
.one("click", function (e) {
if (!moved && !$(e.target).is("a")) {
clickChangeset($(this).data("changeset").id, e);
}
})
.one("mousemove", function () {
moved = true;
});
});
var group = L.featureGroup()
@ -33,17 +35,17 @@ OSM.History = function(map) {
clickChangeset(e.layer.id, e);
});
group.getLayerId = function(layer) {
group.getLayerId = function (layer) {
return layer.id;
};
function highlightChangeset(id) {
group.getLayer(id).setStyle({fillOpacity: 0.3, color: "#FF6600", weight: 3});
group.getLayer(id).setStyle({ fillOpacity: 0.3, color: "#FF6600", weight: 3 });
$("#changeset_" + id).addClass("selected");
}
function unHighlightChangeset(id) {
group.getLayer(id).setStyle({fillOpacity: 0, color: "#FF9500", weight: 2});
group.getLayer(id).setStyle({ fillOpacity: 0, color: "#FF9500", weight: 2 });
$("#changeset_" + id).removeClass("selected");
}
@ -52,7 +54,7 @@ OSM.History = function(map) {
}
function update() {
var data = {list: "1"};
var data = { list: "1" };
if (window.location.pathname === "/history") {
data.bbox = map.getBounds().wrap().toBBoxString();
@ -62,7 +64,7 @@ OSM.History = function(map) {
url: window.location.pathname,
method: "GET",
data: data,
success: function(html) {
success: function (html) {
$("#sidebar_content .changesets").html(html);
updateMap();
}
@ -83,7 +85,7 @@ OSM.History = function(map) {
$(this).hide();
div.find(".loader").show();
$.get($(this).attr("href"), function(data) {
$.get($(this).attr("href"), function (data) {
div.replaceWith(data);
updateMap();
});
@ -94,7 +96,7 @@ OSM.History = function(map) {
function updateBounds() {
group.clearLayers();
changesets.forEach(function(changeset) {
changesets.forEach(function (changeset) {
var bottomLeft = map.project(L.latLng(changeset.bbox.minlat, changeset.bbox.minlon)),
topRight = map.project(L.latLng(changeset.bbox.maxlat, changeset.bbox.maxlon)),
width = topRight.x - bottomLeft.x,
@ -122,14 +124,14 @@ OSM.History = function(map) {
for (var i = 0; i < changesets.length; ++i) {
var changeset = changesets[i],
rect = L.rectangle(changeset.bounds,
{weight: 2, color: "#FF9500", opacity: 1, fillColor: "#FFFFAF", fillOpacity: 0});
{ weight: 2, color: "#FF9500", opacity: 1, fillColor: "#FFFFAF", fillOpacity: 0 });
rect.id = changeset.id;
rect.addTo(group);
}
}
function updateMap() {
changesets = $("[data-changeset]").map(function (index,element) {
changesets = $("[data-changeset]").map(function (index, element) {
return $(element).data("changeset");
}).get().filter(function (changeset) {
return changeset.bbox;
@ -143,12 +145,12 @@ OSM.History = function(map) {
}
}
page.pushstate = page.popstate = function(path) {
page.pushstate = page.popstate = function (path) {
$("#history_tab").addClass("current");
OSM.loadSidebarContent(path, page.load);
};
page.load = function() {
page.load = function () {
map.addLayer(group);
if (window.location.pathname === "/history") {
@ -160,7 +162,7 @@ OSM.History = function(map) {
update();
};
page.unload = function() {
page.unload = function () {
map.removeLayer(group);
map.off("moveend", update);

View file

@ -1,4 +1,4 @@
OSM.NewNote = function(map) {
OSM.NewNote = function (map) {
var noteLayer = map.noteLayer,
content = $("#sidebar_content"),
page = {},
@ -126,7 +126,7 @@ OSM.NewNote = function(map) {
draggable: true
});
newNote.on("dragstart dragend", function(a) {
newNote.on("dragstart dragend", function (a) {
newHalo(newNote.getLatLng(), a.type);
});
@ -135,7 +135,7 @@ OSM.NewNote = function(map) {
newNote.on("remove", function () {
addNoteButton.removeClass("active");
}).on("dragstart",function () {
}).on("dragstart", function () {
$(newNote).stopTime("removenote");
}).on("dragend", function () {
content.find("textarea").focus();

View file

@ -28,7 +28,7 @@ OSM.Note = function (map) {
url: url,
type: method,
oauth: true,
data: {text: $(form.text).val()},
data: { text: $(form.text).val() },
success: function () {
OSM.loadSidebarContent(window.location.pathname, page.load);
}
@ -36,8 +36,8 @@ OSM.Note = function (map) {
}
page.pushstate = page.popstate = function (path) {
OSM.loadSidebarContent(path, function() {
initialize(function() {
OSM.loadSidebarContent(path, function () {
initialize(function () {
var data = $(".details").data(),
latLng = L.latLng(data.coordinates.split(","));
if (!map.getBounds().contains(latLng)) moveToNote();
@ -45,7 +45,7 @@ OSM.Note = function (map) {
});
};
page.load = function() {
page.load = function () {
initialize(moveToNote);
};
@ -101,7 +101,7 @@ OSM.Note = function (map) {
if (!window.location.hash || window.location.hash.match(/^#?c[0-9]+$/)) {
OSM.router.withoutMoveListener(function () {
map.setView(latLng, 15, {reset: true});
map.setView(latLng, 15, { reset: true });
});
}
}

View file

@ -33,7 +33,7 @@ OSM.initializeNotes = function (map) {
}
});
noteLayer.on("click", function(e) {
noteLayer.on("click", function (e) {
if (e.layer.id) {
OSM.router.route("/note/" + e.layer.id);
}
@ -55,7 +55,7 @@ OSM.initializeNotes = function (map) {
return marker;
}
noteLayer.getLayerId = function(marker) {
noteLayer.getLayerId = function (marker) {
return marker.id;
};

View file

@ -1,6 +1,6 @@
//= require jquery.simulate
OSM.Query = function(map) {
OSM.Query = function (map) {
var url = OSM.OVERPASS_URL,
queryButton = $(".control-query .control-button"),
uninterestingTags = ["source", "source_ref", "source:ref", "history", "attribution", "created_by", "tiger:county", "tiger:tlid", "tiger:upload_uuid", "KSJ2:curve_id", "KSJ2:lat", "KSJ2:lon", "KSJ2:coordinate", "KSJ2:filename", "note:ja"],
@ -178,9 +178,9 @@ OSM.Query = function(map) {
url: url,
method: "POST",
data: {
data: "[timeout:10][out:json];" + query,
data: "[timeout:10][out:json];" + query
},
success: function(results) {
success: function (results) {
var elements;
$section.find(".loader").stopTime("loading").hide();
@ -237,7 +237,7 @@ OSM.Query = function(map) {
.appendTo($ul);
}
},
error: function(xhr, status, error) {
error: function (xhr, status, error) {
$section.find(".loader").stopTime("loading").hide();
$("<li>")
@ -301,8 +301,8 @@ OSM.Query = function(map) {
map.removeLayer(marker);
} else {
marker.setStyle({
opacity: 1 - i * 0.1,
fillOpacity: 0.5 - i * 0.05
opacity: 1 - (i * 0.1),
fillOpacity: 0.5 - (i * 0.05)
});
}
}, 10);
@ -335,13 +335,13 @@ OSM.Query = function(map) {
var page = {};
page.pushstate = page.popstate = function(path) {
page.pushstate = page.popstate = function (path) {
OSM.loadSidebarContent(path, function () {
page.load(path, true);
});
};
page.load = function(path, noCentre) {
page.load = function (path, noCentre) {
var params = querystring.parse(path.substring(path.indexOf("?") + 1)),
latlng = L.latLng(params.lat, params.lon);
@ -354,7 +354,7 @@ OSM.Query = function(map) {
queryOverpass(params.lat, params.lon);
};
page.unload = function(sameController) {
page.unload = function (sameController) {
if (!sameController) {
disableQueryMode();
}

View file

@ -1,7 +1,7 @@
//= require jquery.simulate
OSM.Search = function(map) {
$(".search_form input[name=query]").on("input", function(e) {
OSM.Search = function (map) {
$(".search_form input[name=query]").on("input", function (e) {
if ($(e.target).val() === "") {
$(".describe_location").fadeIn(100);
} else {
@ -9,7 +9,7 @@ OSM.Search = function(map) {
}
});
$(".search_form a.button.switch_link").on("click", function(e) {
$(".search_form a.button.switch_link").on("click", function (e) {
e.preventDefault();
var query = $(e.target).parent().parent().find("input[name=query]").val();
if (query) {
@ -19,7 +19,7 @@ OSM.Search = function(map) {
}
});
$(".search_form").on("submit", function(e) {
$(".search_form").on("submit", function (e) {
e.preventDefault();
$("header").addClass("closed");
var query = $(this).find("input[name=query]").val();
@ -30,7 +30,7 @@ OSM.Search = function(map) {
}
});
$(".describe_location").on("click", function(e) {
$(".describe_location").on("click", function (e) {
e.preventDefault();
var center = map.getCenter().wrap(),
precision = OSM.zoomPrecision(map.getZoom());
@ -66,7 +66,7 @@ OSM.Search = function(map) {
$(this).hide();
div.find(".loader").show();
$.get($(this).attr("href"), function(data) {
$.get($(this).attr("href"), function (data) {
div.replaceWith(data);
});
}
@ -77,7 +77,7 @@ OSM.Search = function(map) {
if (!marker) {
var data = $(this).find("a.set_position").data();
marker = L.marker([data.lat, data.lon], {icon: OSM.getUserIcon()});
marker = L.marker([data.lat, data.lon], { icon: OSM.getUserIcon() });
$(this).data("marker", marker);
}
@ -119,15 +119,15 @@ OSM.Search = function(map) {
var page = {};
page.pushstate = page.popstate = function(path) {
page.pushstate = page.popstate = function (path) {
var params = querystring.parse(path.substring(path.indexOf("?") + 1));
$(".search_form input[name=query]").val(params.query);
$(".describe_location").hide();
OSM.loadSidebarContent(path, page.load);
};
page.load = function() {
$(".search_results_entry").each(function(index) {
page.load = function () {
$(".search_results_entry").each(function (index) {
var entry = $(this);
$.ajax({
url: entry.data("href"),
@ -139,7 +139,7 @@ OSM.Search = function(map) {
maxlon: map.getBounds().getEast(),
maxlat: map.getBounds().getNorth()
},
success: function(html) {
success: function (html) {
entry.html(html);
// go to first result of first geocoder
if (index === 0) {
@ -155,7 +155,7 @@ OSM.Search = function(map) {
return map.getState();
};
page.unload = function() {
page.unload = function () {
markers.clearLayers();
$(".search_form input[name=query]").val("");
$(".describe_location").fadeIn(100);

View file

@ -1,4 +1,4 @@
L.OSM.layers = function(options) {
L.OSM.layers = function (options) {
var control = L.control(options);
control.onAdd = function (map) {
@ -37,7 +37,7 @@ L.OSM.layers = function(options) {
var baseLayers = $("<ul>")
.appendTo(baseSection);
layers.forEach(function(layer) {
layers.forEach(function (layer) {
var item = $("<li>")
.appendTo(baseLayers);
@ -48,8 +48,8 @@ L.OSM.layers = function(options) {
var div = $("<div>")
.appendTo(item);
map.whenReady(function() {
var miniMap = L.map(div[0], {attributionControl: false, zoomControl: false, keyboard: false})
map.whenReady(function () {
var miniMap = L.map(div[0], { attributionControl: false, zoomControl: false, keyboard: false })
.addLayer(new layer.constructor({ apikey: layer.options.apikey }));
miniMap.dragging.disable();
@ -63,7 +63,7 @@ L.OSM.layers = function(options) {
function shown() {
miniMap.invalidateSize();
setView({animate: false});
setView({ animate: false });
map.on("moveend", moved);
}
@ -90,20 +90,20 @@ L.OSM.layers = function(options) {
label.append(layer.options.name);
item.on("click", function() {
layers.forEach(function(other) {
item.on("click", function () {
layers.forEach(function (other) {
if (other === layer) {
map.addLayer(other);
} else {
map.removeLayer(other);
}
});
map.fire("baselayerchange", {layer: layer});
map.fire("baselayerchange", { layer: layer });
});
item.on("dblclick", toggle);
map.on("layeradd layerremove", function() {
map.on("layeradd layerremove", function () {
item.toggleClass("active", map.hasLayer(layer));
input.prop("checked", map.hasLayer(layer));
});
@ -141,21 +141,21 @@ L.OSM.layers = function(options) {
label.append(I18n.t("javascripts.map.layers." + name));
input.on("change", function() {
input.on("change", function () {
checked = input.is(":checked");
if (checked) {
map.addLayer(layer);
} else {
map.removeLayer(layer);
}
map.fire("overlaylayerchange", {layer: layer});
map.fire("overlaylayerchange", { layer: layer });
});
map.on("layeradd layerremove", function() {
map.on("layeradd layerremove", function () {
input.prop("checked", map.hasLayer(layer));
});
map.on("zoomend", function() {
map.on("zoomend", function () {
var disabled = map.getBounds().getSize() >= maxArea;
$(input).prop("disabled", disabled);

View file

@ -10,11 +10,11 @@ L.extend(L.LatLngBounds.prototype, {
});
L.OSM.Map = L.Map.extend({
initialize: function(id, options) {
initialize: function (id, options) {
L.Map.prototype.initialize.call(this, id, options);
var copyright = I18n.t("javascripts.map.copyright", {copyright_url: "/copyright"});
var donate = I18n.t("javascripts.map.donate_link_text", {donate_url: "https://donate.openstreetmap.org"});
var copyright = I18n.t("javascripts.map.copyright", { copyright_url: "/copyright" });
var donate = I18n.t("javascripts.map.donate_link_text", { donate_url: "https://donate.openstreetmap.org" });
this.baseLayers = [];
@ -51,7 +51,7 @@ L.OSM.Map = L.Map.extend({
}));
this.noteLayer = new L.FeatureGroup();
this.noteLayer.options = {code: "N"};
this.noteLayer.options = { code: "N" };
this.dataLayer = new L.OSM.DataLayer(null);
this.dataLayer.options.code = "D";
@ -69,7 +69,7 @@ L.OSM.Map = L.Map.extend({
});
},
updateLayers: function(layerParam) {
updateLayers: function (layerParam) {
layerParam = layerParam || "M";
var layersAdded = "";
@ -103,7 +103,7 @@ L.OSM.Map = L.Map.extend({
return baseLayer.keyid;
},
getUrl: function(marker) {
getUrl: function (marker) {
var precision = OSM.zoomPrecision(this.getZoom()),
params = {};
@ -123,7 +123,7 @@ L.OSM.Map = L.Map.extend({
return url;
},
getShortUrl: function(marker) {
getShortUrl: function (marker) {
var zoom = this.getZoom(),
latLng = marker && this.hasLayer(marker) ? marker.getLatLng().wrap() : this.getCenter().wrap(),
str = window.location.hostname.match(/^www\.openstreetmap\.org/i) ?
@ -140,11 +140,11 @@ L.OSM.Map = L.Map.extend({
i;
for (i = 0; i < Math.ceil((zoom + 8) / 3.0) && i < 5; ++i) {
digit = (c1 >> (24 - 6 * i)) & 0x3f;
digit = (c1 >> (24 - (6 * i))) & 0x3f;
str += char_array.charAt(digit);
}
for (i = 5; i < Math.ceil((zoom + 8) / 3.0); ++i) {
digit = (c2 >> (24 - 6 * (i - 5))) & 0x3f;
digit = (c2 >> (24 - (6 * (i - 5)))) & 0x3f;
str += char_array.charAt(digit);
}
for (i = 0; i < ((zoom + 8) % 3); ++i) str += "-";
@ -185,7 +185,7 @@ L.OSM.Map = L.Map.extend({
return str;
},
getGeoUri: function(marker) {
getGeoUri: function (marker) {
var precision = OSM.zoomPrecision(this.getZoom()),
latLng,
params = {};
@ -203,7 +203,7 @@ L.OSM.Map = L.Map.extend({
return "geo:" + params.lat + "," + params.lon + "?z=" + params.zoom;
},
addObject: function(object, callback) {
addObject: function (object, callback) {
var objectStyle = {
color: "#FF6200",
weight: 4,
@ -241,9 +241,9 @@ L.OSM.Map = L.Map.extend({
if (object.type === "node") {
return true;
} else if (object.type === "relation") {
for (var i = 0; i < relations.length; i++)
if (relations[i].members.indexOf(node) !== -1)
return true;
for (var i = 0; i < relations.length; i++) {
if (relations[i].members.indexOf(node) !== -1) return true;
}
} else {
return false;
}
@ -257,13 +257,13 @@ L.OSM.Map = L.Map.extend({
});
},
removeObject: function() {
removeObject: function () {
this._object = null;
if (this._objectLoader) this._objectLoader.abort();
if (this._objectLayer) this.removeLayer(this._objectLayer);
},
getState: function() {
getState: function () {
return {
center: this.getCenter().wrap(),
zoom: this.getZoom(),
@ -271,20 +271,20 @@ L.OSM.Map = L.Map.extend({
};
},
setState: function(state, options) {
setState: function (state, options) {
if (state.center) this.setView(state.center, state.zoom, options);
if (state.layers) this.updateLayers(state.layers);
},
setSidebarOverlaid: function(overlaid) {
setSidebarOverlaid: function (overlaid) {
if (overlaid && !$("#content").hasClass("overlay-sidebar")) {
$("#content").addClass("overlay-sidebar");
this.invalidateSize({pan: false})
.panBy([-350, 0], {animate: false});
this.invalidateSize({ pan: false })
.panBy([-350, 0], { animate: false });
} else if (!overlaid && $("#content").hasClass("overlay-sidebar")) {
this.panBy([350, 0], {animate: false});
this.panBy([350, 0], { animate: false });
$("#content").removeClass("overlay-sidebar");
this.invalidateSize({pan: false});
this.invalidateSize({ pan: false });
}
return this;
}
@ -301,7 +301,7 @@ L.Icon.Default.imageUrls = {
L.extend(L.Icon.Default.prototype, {
_oldGetIconUrl: L.Icon.Default.prototype._getIconUrl,
_getIconUrl: function (name) {
_getIconUrl: function (name) {
var url = this._oldGetIconUrl(name);
return L.Icon.Default.imageUrls[url];
}

View file

@ -1,6 +1,6 @@
L.OSM.share = function (options) {
var control = L.control(options),
marker = L.marker([0, 0], {draggable: true}),
marker = L.marker([0, 0], { draggable: true }),
locationFilter = new L.LocationFilter({
enableButton: false,
adjustButton: false
@ -76,7 +76,7 @@ L.OSM.share = function (options) {
.attr("for", "embed_html")
.attr("href", "#")
.text(I18n.t("javascripts.share.embed")))
.on("click", "a", function(e) {
.on("click", "a", function (e) {
e.preventDefault();
var id = "#" + $(this).attr("for");
$linkSection.find(".share-tabs a")
@ -199,7 +199,7 @@ L.OSM.share = function (options) {
.attr("type", "text")
.on("change", update));
["minlon", "minlat", "maxlon", "maxlat"].forEach(function(name) {
["minlon", "minlat", "maxlon", "maxlat"].forEach(function (name) {
$("<input>")
.attr("id", "mapnik_" + name)
.attr("name", name)
@ -313,7 +313,7 @@ L.OSM.share = function (options) {
"\"": "&quot;",
"'": "&#x27;"
};
return string === null ? "" : String(string).replace(/[&<>"']/g, function(match) {
return string === null ? "" : String(string).replace(/[&<>"']/g, function (match) {
return htmlEscapes[match];
});
}

View file

@ -1,4 +1,4 @@
L.OSM.sidebar = function(selector) {
L.OSM.sidebar = function (selector) {
var control = {},
sidebar = $(selector),
current = $(),
@ -10,13 +10,13 @@ L.OSM.sidebar = function(selector) {
return control;
};
control.addPane = function(pane) {
control.addPane = function (pane) {
pane
.hide()
.appendTo(sidebar);
};
control.togglePane = function(pane, button) {
control.togglePane = function (pane, button) {
current
.hide()
.trigger("hide");
@ -33,7 +33,7 @@ L.OSM.sidebar = function(selector) {
currentButton = button || $();
}
map.invalidateSize({pan: false, animate: false});
map.invalidateSize({ pan: false, animate: false });
current
.show()

View file

@ -1,4 +1,4 @@
$(document).ready(function() {
$(document).ready(function () {
// Preserve location hash in referer
if (window.location.hash) {
$("#referer").val($("#referer").val() + window.location.hash);
@ -12,7 +12,7 @@ $(document).ready(function() {
});
// Add click handler to show OpenID field
$("#openid_open_url").click(function() {
$("#openid_open_url").click(function () {
$("#openid_url").val("http://");
$("#login_auth_buttons").hide();
$("#login_openid_url").show();
@ -24,7 +24,7 @@ $(document).ready(function() {
$("#login_openid_submit").hide();
// Handle OpenID submission by redirecting to omniauth
$("#openid_login_form").submit(function() {
$("#openid_login_form").submit(function () {
var action = $(this).prop("action"),
openid_url = $(this).find("#openid_url").val(),
referer = $(this).find("#openid_referer").val(),

View file

@ -17,7 +17,7 @@ $(document).ready(function () {
token_secret: application_data.tokenSecret
});
$.ajaxPrefilter(function(options, jqxhr) {
$.ajaxPrefilter(function (options, jqxhr) {
if (options.oauth) {
options.headers = options.headers || {};
options.headers.Authorization = headerGenerator(options.type, makeAbsolute(options.url), jqxhr.data);

View file

@ -46,7 +46,7 @@
`OSM.router.withoutMoveListener` to run a block of code that may update
move the map without the hash changing.
*/
OSM.Router = function(map, rts) {
OSM.Router = function (map, rts) {
var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g;
var optionalParam = /\((.*?)\)/g;
var namedParam = /(\(\?)?:\w+/g;
@ -56,22 +56,22 @@ OSM.Router = function(map, rts) {
var regexp = new RegExp("^" +
path.replace(escapeRegExp, "\\$&")
.replace(optionalParam, "(?:$1)?")
.replace(namedParam, function(match, optional){
.replace(namedParam, function (match, optional) {
return optional ? match : "([^\/]+)";
})
.replace(splatParam, "(.*?)") + "(?:\\?.*)?$");
var route = {};
route.match = function(path) {
route.match = function (path) {
return regexp.test(path);
};
route.run = function(action, path) {
route.run = function (action, path) {
var params = [];
if (path) {
params = regexp.exec(path).map(function(param, i) {
params = regexp.exec(path).map(function (param, i) {
return (i > 0 && param) ? decodeURIComponent(param) : param;
});
}
@ -85,10 +85,11 @@ OSM.Router = function(map, rts) {
}
var routes = [];
for (var r in rts)
for (var r in rts) {
routes.push(new Route(r, rts[r]));
}
routes.recognize = function(path) {
routes.recognize = function (path) {
for (var i = 0; i < this.length; i++) {
if (this[i].match(path)) return this[i];
}
@ -101,7 +102,7 @@ OSM.Router = function(map, rts) {
var router = {};
if (window.history && window.history.pushState) {
$(window).on("popstate", function(e) {
$(window).on("popstate", function (e) {
if (!e.originalEvent.state) return; // Is it a real popstate event or just a hash change?
var path = window.location.pathname + window.location.search,
route = routes.recognize(path);
@ -110,7 +111,7 @@ OSM.Router = function(map, rts) {
currentPath = path;
currentRoute = route;
currentRoute.run("popstate", currentPath);
map.setState(e.originalEvent.state, {animate: false});
map.setState(e.originalEvent.state, { animate: false });
});
router.route = function (url) {
@ -131,7 +132,7 @@ OSM.Router = function(map, rts) {
window.history.replaceState(OSM.parseHash(url), document.title, url);
};
router.stateChange = function(state) {
router.stateChange = function (state) {
if (state.center) {
window.history.replaceState(state, document.title, OSM.formatHash(state));
} else {
@ -143,19 +144,19 @@ OSM.Router = function(map, rts) {
window.location.assign(url);
};
router.stateChange = function(state) {
router.stateChange = function (state) {
if (state.center) window.location.replace(OSM.formatHash(state));
};
}
router.updateHash = function() {
router.updateHash = function () {
var hash = OSM.formatHash(map);
if (hash === currentHash) return;
currentHash = hash;
router.stateChange(OSM.parseHash(hash));
};
router.hashUpdated = function() {
router.hashUpdated = function () {
var hash = location.hash;
if (hash === currentHash) return;
currentHash = hash;
@ -177,7 +178,7 @@ OSM.Router = function(map, rts) {
map.off("movestart", disableMoveListener);
};
router.load = function() {
router.load = function () {
var loadState = currentRoute.run("load", currentPath);
router.stateChange(loadState || {});
};

View file

@ -9,7 +9,7 @@ $(document).ready(function () {
var position = $("html").attr("dir") === "rtl" ? "topleft" : "topright";
L.OSM.zoom({position: position})
L.OSM.zoom({ position: position })
.addTo(map);
var locate = L.control.locate({
@ -39,7 +39,7 @@ $(document).ready(function () {
}
if ($("#map").hasClass("set_location")) {
var marker = L.marker([0, 0], {icon: OSM.getUserIcon()});
var marker = L.marker([0, 0], { icon: OSM.getUserIcon() });
if (OSM.home) {
marker.setLatLng([OSM.home.lat, OSM.home.lon]);
@ -64,7 +64,7 @@ $(document).ready(function () {
$("[data-user]").each(function () {
var user = $(this).data("user");
if (user.lon && user.lat) {
L.marker([user.lat, user.lon], {icon: OSM.getUserIcon(user.icon)}).addTo(map)
L.marker([user.lat, user.lon], { icon: OSM.getUserIcon(user.icon) }).addTo(map)
.bindPopup(user.description);
}
});

View file

@ -1,4 +1,4 @@
$(document).ready(function() {
$(document).ready(function () {
var params = OSM.params();
if (params.lat && params.lon) {
@ -15,7 +15,6 @@ $(document).ready(function() {
url += OSM.formatHash(params);
$(".start-mapping").attr("href", url);
} else {
var geoSuccess = function (position) {
window.location = "/edit" + OSM.formatHash({
@ -25,7 +24,7 @@ $(document).ready(function() {
});
};
$(".start-mapping").on("click", function(e) {
$(".start-mapping").on("click", function (e) {
e.preventDefault();
$(".start-mapping").addClass("loading");

View file

@ -18,12 +18,25 @@
},
"rules": {
"accessor-pairs": "error",
"array-bracket-newline": ["error", "consistent"],
"array-bracket-spacing": "error",
"array-callback-return": "error",
"block-scoped-var": "error",
"block-spacing": "error",
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"comma-dangle": "error",
"comma-spacing": "error",
"comma-style": "error",
"computed-property-spacing": "error",
"curly": ["error", "multi-line", "consistent"],
"dot-notation": "error",
"eol-last": "error",
"eqeqeq": ["error", "smart"],
"func-call-spacing": "error",
"key-spacing": "error",
"keyword-spacing": "error",
"no-alert": "warn",
"no-array-constructor": "error",
"no-caller": "error",
"no-div-regex": "error",
"no-eval": "error",
@ -38,10 +51,16 @@
"no-labels": "error",
"no-label-var": "error",
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-loop-func": "error",
"no-mixed-operators": "error",
"no-multiple-empty-lines": "error",
"no-multi-str": "error",
"no-negated-condition": "error",
"no-nested-ternary": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-process-env": "error",
@ -59,15 +78,28 @@
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-return": "error",
"no-use-before-define": ["error", {"functions": false}],
"no-use-before-define": ["error", { "functions": false }],
"no-void": "error",
"no-warning-comments": "warn",
"no-whitespace-before-property": "error",
"no-with": "error",
"object-curly-newline": ["error", { "consistent": true }],
"object-curly-spacing": ["error", "always"],
"object-property-newline": ["error", { "allowAllPropertiesOnSameLine": true }],
"operator-linebreak": ["error", "after"],
"padded-blocks": ["error", "never"],
"quote-props": ["error", "consistent-as-needed", { "keywords": true, "numbers": true }],
"quotes": ["error", "double"],
"radix": ["error", "always"],
"semi": ["error", "always"],
"semi-spacing": "error",
"semi-style": "error",
"space-before-blocks": "error",
"space-before-function-paren": ["error", { "named": "never" }],
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"switch-colon-spacing": "error",
"wrap-iife": "error",
"wrap-regex": "error",
"yoda": "error"