Enforce consistent indentation in javascript code

This commit is contained in:
Tom Hughes 2019-07-14 10:52:18 +01:00
parent 807750023a
commit c4c0e8105a
20 changed files with 160 additions and 153 deletions

View file

@ -26,8 +26,8 @@ var qs = require("querystring-component");
window.updateLinks = function (loc, zoom, layers, object) { window.updateLinks = function (loc, zoom, layers, object) {
$(".geolink").each(function (index, link) { $(".geolink").each(function (index, link) {
var href = link.href.split(/[?#]/)[0], var href = link.href.split(/[?#]/)[0],
args = qs.parse(link.search.substring(1)), args = qs.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;

View file

@ -27,8 +27,8 @@ document.addEventListener("DOMContentLoaded", function () {
id.map().on("move.embed", parent.$.throttle(250, function () { id.map().on("move.embed", parent.$.throttle(250, function () {
if (id.inIntro()) return; if (id.inIntro()) return;
var zoom = ~~id.map().zoom(), var zoom = ~~id.map().zoom(),
center = id.map().center(), center = id.map().center(),
llz = { lon: center[0], lat: center[1], zoom: zoom }; llz = { lon: center[0], lat: center[1], zoom: zoom };
parent.updateLinks(llz, zoom); parent.updateLinks(llz, zoom);

View file

@ -234,7 +234,7 @@ $(document).ready(function () {
e.preventDefault(); e.preventDefault();
var data = $(this).data(), var data = $(this).data(),
center = L.latLng(data.lat, data.lon); center = L.latLng(data.lat, data.lon);
map.setView(center, data.zoom); map.setView(center, data.zoom);
L.marker(center, { icon: OSM.getUserIcon() }).addTo(map); L.marker(center, { icon: OSM.getUserIcon() }).addTo(map);
@ -260,13 +260,13 @@ $(document).ready(function () {
if (object) query.select = object.type + object.id; if (object) query.select = object.type + object.id;
var iframe = $("<iframe>") var iframe = $("<iframe>")
.hide() .hide()
.appendTo("body") .appendTo("body")
.attr("src", url + querystring.stringify(query)) .attr("src", url + querystring.stringify(query))
.on("load", function () { .on("load", function () {
$(this).remove(); $(this).remove();
loaded = true; loaded = true;
}); });
setTimeout(function () { setTimeout(function () {
if (!loaded) { if (!loaded) {

View file

@ -1,7 +1,7 @@
OSM.Changeset = function (map) { OSM.Changeset = function (map) {
var page = {}, var page = {},
content = $("#sidebar_content"), content = $("#sidebar_content"),
currentChangesetId; currentChangesetId;
page.pushstate = page.popstate = function (path, id) { page.pushstate = page.popstate = function (path, id) {
OSM.loadSidebarContent(path, function () { OSM.loadSidebarContent(path, function () {

View file

@ -260,11 +260,11 @@ OSM.Directions = function (map) {
// Add each row // Add each row
route.steps.forEach(function (step) { route.steps.forEach(function (step) {
var ll = step[0], var ll = step[0],
direction = step[1], direction = step[1],
instruction = step[2], instruction = step[2],
dist = step[3], dist = step[3],
lineseg = step[4]; lineseg = step[4];
if (dist < 5) { if (dist < 5) {
dist = ""; dist = "";

View file

@ -43,9 +43,9 @@ OSM.Export = function (map) {
$("#maxlat").val(bounds.getNorth().toFixed(precision)); $("#maxlat").val(bounds.getNorth().toFixed(precision));
$("#export_overpass").attr("href", $("#export_overpass").attr("href",
"https://overpass-api.de/api/map?bbox=" + "https://overpass-api.de/api/map?bbox=" +
$("#minlon").val() + "," + $("#minlat").val() + "," + $("#minlon").val() + "," + $("#minlat").val() + "," +
$("#maxlon").val() + "," + $("#maxlat").val()); $("#maxlon").val() + "," + $("#maxlat").val());
} }
function validateControls() { function validateControls() {

View file

@ -71,7 +71,7 @@ OSM.History = function (map) {
}); });
var feedLink = $("link[type=\"application/atom+xml\"]"), var feedLink = $("link[type=\"application/atom+xml\"]"),
feedHref = feedLink.attr("href").split("?")[0]; feedHref = feedLink.attr("href").split("?")[0];
feedLink.attr("href", feedHref + "?bbox=" + data.bbox); feedLink.attr("href", feedHref + "?bbox=" + data.bbox);
} }
@ -123,8 +123,8 @@ OSM.History = function (map) {
for (var i = 0; i < changesets.length; ++i) { for (var i = 0; i < changesets.length; ++i) {
var changeset = changesets[i], var changeset = changesets[i],
rect = L.rectangle(changeset.bounds, 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.id = changeset.id;
rect.addTo(group); rect.addTo(group);
} }

View file

@ -1,10 +1,10 @@
OSM.NewNote = function (map) { OSM.NewNote = function (map) {
var noteLayer = map.noteLayer, var noteLayer = map.noteLayer,
content = $("#sidebar_content"), content = $("#sidebar_content"),
page = {}, page = {},
addNoteButton = $(".control-note .control-button"), addNoteButton = $(".control-note .control-button"),
newNote, newNote,
halo; halo;
var noteIcons = { var noteIcons = {
"new": L.icon({ "new": L.icon({

View file

@ -1,7 +1,7 @@
OSM.Note = function (map) { OSM.Note = function (map) {
var content = $("#sidebar_content"), var content = $("#sidebar_content"),
page = {}, page = {},
halo, currentNote; halo, currentNote;
var noteIcons = { var noteIcons = {
"new": L.icon({ "new": L.icon({
@ -39,7 +39,7 @@ OSM.Note = function (map) {
OSM.loadSidebarContent(path, function () { OSM.loadSidebarContent(path, function () {
initialize(function () { initialize(function () {
var data = $(".details").data(), var data = $(".details").data(),
latLng = L.latLng(data.coordinates.split(",")); latLng = L.latLng(data.coordinates.split(","));
if (!map.getBounds().contains(latLng)) moveToNote(); if (!map.getBounds().contains(latLng)) moveToNote();
}); });
}); });
@ -71,7 +71,7 @@ OSM.Note = function (map) {
content.find("textarea").val("").trigger("input"); content.find("textarea").val("").trigger("input");
var data = $(".details").data(), var data = $(".details").data(),
latLng = L.latLng(data.coordinates.split(",")); latLng = L.latLng(data.coordinates.split(","));
if (!map.hasLayer(halo)) { if (!map.hasLayer(halo)) {
halo = L.circleMarker(latLng, { halo = L.circleMarker(latLng, {
@ -97,7 +97,7 @@ OSM.Note = function (map) {
function moveToNote() { function moveToNote() {
var data = $(".details").data(), var data = $(".details").data(),
latLng = L.latLng(data.coordinates.split(",")); latLng = L.latLng(data.coordinates.split(","));
if (!window.location.hash || window.location.hash.match(/^#?c[0-9]+$/)) { if (!window.location.hash || window.location.hash.match(/^#?c[0-9]+$/)) {
OSM.router.withoutMoveListener(function () { OSM.router.withoutMoveListener(function () {

View file

@ -2,9 +2,9 @@
OSM.Query = function (map) { OSM.Query = function (map) {
var url = OSM.OVERPASS_URL, var url = OSM.OVERPASS_URL,
queryButton = $(".control-query .control-button"), 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"], 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"],
marker; marker;
var featureStyle = { var featureStyle = {
color: "#FF6200", color: "#FF6200",
@ -103,7 +103,7 @@ OSM.Query = function (map) {
if (prefixes[key]) { if (prefixes[key]) {
var first = value.substr(0, 1).toUpperCase(), var first = value.substr(0, 1).toUpperCase(),
rest = value.substr(1).replace(/_/g, " "); rest = value.substr(1).replace(/_/g, " ");
return first + rest; return first + rest;
} }
@ -119,7 +119,7 @@ OSM.Query = function (map) {
function featureName(feature) { function featureName(feature) {
var tags = feature.tags, var tags = feature.tags,
locales = I18n.locales.get(); locales = I18n.locales.get();
for (var i = 0; i < locales.length; i++) { for (var i = 0; i < locales.length; i++) {
if (tags["name:" + locales[i]]) { if (tags["name:" + locales[i]]) {
@ -249,11 +249,11 @@ OSM.Query = function (map) {
function compareSize(feature1, feature2) { function compareSize(feature1, feature2) {
var width1 = feature1.bounds.maxlon - feature1.bounds.minlon, var width1 = feature1.bounds.maxlon - feature1.bounds.minlon,
height1 = feature1.bounds.maxlat - feature1.bounds.minlat, height1 = feature1.bounds.maxlat - feature1.bounds.minlat,
area1 = width1 * height1, area1 = width1 * height1,
width2 = feature2.bounds.maxlat - feature2.bounds.minlat, width2 = feature2.bounds.maxlat - feature2.bounds.minlat,
height2 = feature2.bounds.maxlat - feature2.bounds.minlat, height2 = feature2.bounds.maxlat - feature2.bounds.minlat,
area2 = width2 * height2; area2 = width2 * height2;
return area1 - area2; return area1 - area2;
} }
@ -280,15 +280,15 @@ OSM.Query = function (map) {
*/ */
function queryOverpass(lat, lng) { function queryOverpass(lat, lng) {
var latlng = L.latLng(lat, lng).wrap(), var latlng = L.latLng(lat, lng).wrap(),
bounds = map.getBounds().wrap(), bounds = map.getBounds().wrap(),
bbox = bounds.getSouth() + "," + bounds.getWest() + "," + bounds.getNorth() + "," + bounds.getEast(), bbox = bounds.getSouth() + "," + bounds.getWest() + "," + bounds.getNorth() + "," + bounds.getEast(),
radius = 10 * Math.pow(1.5, 19 - map.getZoom()), radius = 10 * Math.pow(1.5, 19 - map.getZoom()),
around = "around:" + radius + "," + lat + "," + lng, around = "around:" + radius + "," + lat + "," + lng,
nodes = "node(" + around + ")", nodes = "node(" + around + ")",
ways = "way(" + around + ")", ways = "way(" + around + ")",
relations = "relation(" + around + ")", relations = "relation(" + around + ")",
nearby = "(" + nodes + ";" + ways + ";);out tags geom(" + bbox + ");" + relations + ";out geom(" + bbox + ");", nearby = "(" + nodes + ";" + ways + ";);out tags geom(" + bbox + ");" + relations + ";out geom(" + bbox + ");",
isin = "is_in(" + lat + "," + lng + ")->.a;way(pivot.a);out tags bb;out ids geom(" + bbox + ");relation(pivot.a);out tags bb;"; isin = "is_in(" + lat + "," + lng + ")->.a;way(pivot.a);out tags bb;out ids geom(" + bbox + ");relation(pivot.a);out tags bb;";
$("#sidebar_content .query-intro") $("#sidebar_content .query-intro")
.hide(); .hide();
@ -313,9 +313,9 @@ OSM.Query = function (map) {
function clickHandler(e) { function clickHandler(e) {
var precision = OSM.zoomPrecision(map.getZoom()), var precision = OSM.zoomPrecision(map.getZoom()),
latlng = e.latlng.wrap(), latlng = e.latlng.wrap(),
lat = latlng.lat.toFixed(precision), lat = latlng.lat.toFixed(precision),
lng = latlng.lng.toFixed(precision); lng = latlng.lng.toFixed(precision);
OSM.router.route("/query?lat=" + lat + "&lon=" + lng); OSM.router.route("/query?lat=" + lat + "&lon=" + lng);
} }
@ -343,7 +343,7 @@ OSM.Query = function (map) {
page.load = function (path, noCentre) { page.load = function (path, noCentre) {
var params = querystring.parse(path.substring(path.indexOf("?") + 1)), var params = querystring.parse(path.substring(path.indexOf("?") + 1)),
latlng = L.latLng(params.lat, params.lon); latlng = L.latLng(params.lat, params.lon);
if (!window.location.hash && !noCentre && !map.getBounds().contains(latlng)) { if (!window.location.hash && !noCentre && !map.getBounds().contains(latlng)) {
OSM.router.withoutMoveListener(function () { OSM.router.withoutMoveListener(function () {

View file

@ -33,7 +33,7 @@ OSM.Search = function (map) {
$(".describe_location").on("click", function (e) { $(".describe_location").on("click", function (e) {
e.preventDefault(); e.preventDefault();
var center = map.getCenter().wrap(), var center = map.getCenter().wrap(),
precision = OSM.zoomPrecision(map.getZoom()); precision = OSM.zoomPrecision(map.getZoom());
OSM.router.route("/search?whereami=1&query=" + encodeURIComponent( OSM.router.route("/search?whereami=1&query=" + encodeURIComponent(
center.lat.toFixed(precision) + "," + center.lng.toFixed(precision) center.lat.toFixed(precision) + "," + center.lng.toFixed(precision)
)); ));

View file

@ -65,13 +65,13 @@ L.OSM.key = function (options) {
.toggleClass("disabled", disabled) .toggleClass("disabled", disabled)
.attr("data-original-title", .attr("data-original-title",
I18n.t(disabled ? I18n.t(disabled ?
"javascripts.key.tooltip_disabled" : "javascripts.key.tooltip_disabled" :
"javascripts.key.tooltip")); "javascripts.key.tooltip"));
} }
function update() { function update() {
var layer = map.getMapBaseLayerId(), var layer = map.getMapBaseLayerId(),
zoom = map.getZoom(); zoom = map.getZoom();
$(".mapkey-table-entry").each(function () { $(".mapkey-table-entry").each(function () {
var data = $(this).data(); var data = $(this).data();

View file

@ -84,9 +84,9 @@ L.OSM.layers = function (options) {
.appendTo(item); .appendTo(item);
var input = $("<input>") var input = $("<input>")
.attr("type", "radio") .attr("type", "radio")
.prop("checked", map.hasLayer(layer)) .prop("checked", map.hasLayer(layer))
.appendTo(label); .appendTo(label);
label.append(layer.options.name); label.append(layer.options.name);

View file

@ -115,8 +115,8 @@ L.OSM.Map = L.Map.extend({
} }
var url = window.location.protocol + "//" + OSM.SERVER_URL + "/", var url = window.location.protocol + "//" + OSM.SERVER_URL + "/",
query = querystring.stringify(params), query = querystring.stringify(params),
hash = OSM.formatHash(this); hash = OSM.formatHash(this);
if (query) url += "?" + query; if (query) url += "?" + query;
if (hash) url += hash; if (hash) url += hash;
@ -126,19 +126,19 @@ L.OSM.Map = L.Map.extend({
getShortUrl: function (marker) { getShortUrl: function (marker) {
var zoom = this.getZoom(), var zoom = this.getZoom(),
latLng = marker && this.hasLayer(marker) ? marker.getLatLng().wrap() : this.getCenter().wrap(), latLng = marker && this.hasLayer(marker) ? marker.getLatLng().wrap() : this.getCenter().wrap(),
str = window.location.hostname.match(/^www\.openstreetmap\.org/i) ? str = window.location.hostname.match(/^www\.openstreetmap\.org/i) ?
window.location.protocol + "//osm.org/go/" : window.location.protocol + "//osm.org/go/" :
window.location.protocol + "//" + window.location.hostname + "/go/", window.location.protocol + "//" + window.location.hostname + "/go/",
char_array = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_~", char_array = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_~",
x = Math.round((latLng.lng + 180.0) * ((1 << 30) / 90.0)), x = Math.round((latLng.lng + 180.0) * ((1 << 30) / 90.0)),
y = Math.round((latLng.lat + 90.0) * ((1 << 30) / 45.0)), y = Math.round((latLng.lat + 90.0) * ((1 << 30) / 45.0)),
// JavaScript only has to keep 32 bits of bitwise operators, so this has to be // JavaScript only has to keep 32 bits of bitwise operators, so this has to be
// done in two parts. each of the parts c1/c2 has 30 bits of the total in it // done in two parts. each of the parts c1/c2 has 30 bits of the total in it
// and drops the last 4 bits of the full 64 bit Morton code. // and drops the last 4 bits of the full 64 bit Morton code.
c1 = interlace(x >>> 17, y >>> 17), c2 = interlace((x >>> 2) & 0x7fff, (y >>> 2) & 0x7fff), c1 = interlace(x >>> 17, y >>> 17), c2 = interlace((x >>> 2) & 0x7fff, (y >>> 2) & 0x7fff),
digit, digit,
i; i;
for (i = 0; i < Math.ceil((zoom + 8) / 3.0) && i < 5; ++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;

View file

@ -17,7 +17,7 @@ L.OSM.query = function (options) {
function update() { function update() {
var wasDisabled = link.hasClass("disabled"), var wasDisabled = link.hasClass("disabled"),
isDisabled = map.getZoom() < 14; isDisabled = map.getZoom() < 14;
link link
.toggleClass("disabled", isDisabled) .toggleClass("disabled", isDisabled)
.attr("data-original-title", I18n.t(isDisabled ? .attr("data-original-title", I18n.t(isDisabled ?

View file

@ -1,10 +1,10 @@
L.OSM.share = function (options) { L.OSM.share = function (options) {
var control = L.control(options), var control = L.control(options),
marker = L.marker([0, 0], { draggable: true }), marker = L.marker([0, 0], { draggable: true }),
locationFilter = new L.LocationFilter({ locationFilter = new L.LocationFilter({
enableButton: false, enableButton: false,
adjustButton: false adjustButton: false
}); });
control.onAdd = function (map) { control.onAdd = function (map) {
var $container = $("<div>") var $container = $("<div>")
@ -364,9 +364,9 @@ L.OSM.share = function (options) {
} }
var scale = $("#mapnik_scale").val(), var scale = $("#mapnik_scale").val(),
size = L.bounds(L.CRS.EPSG3857.project(bounds.getSouthWest()), size = L.bounds(L.CRS.EPSG3857.project(bounds.getSouthWest()),
L.CRS.EPSG3857.project(bounds.getNorthEast())).getSize(), L.CRS.EPSG3857.project(bounds.getNorthEast())).getSize(),
maxScale = Math.floor(Math.sqrt(size.x * size.y / 0.3136)); maxScale = Math.floor(Math.sqrt(size.x * size.y / 0.3136));
$("#mapnik_minlon").val(bounds.getWest()); $("#mapnik_minlon").val(bounds.getWest());
$("#mapnik_minlat").val(bounds.getSouth()); $("#mapnik_minlat").val(bounds.getSouth());
@ -396,11 +396,11 @@ L.OSM.share = function (options) {
function getScale() { function getScale() {
var bounds = map.getBounds(), var bounds = map.getBounds(),
centerLat = bounds.getCenter().lat, centerLat = bounds.getCenter().lat,
halfWorldMeters = 6378137 * Math.PI * Math.cos(centerLat * Math.PI / 180), halfWorldMeters = 6378137 * Math.PI * Math.cos(centerLat * Math.PI / 180),
meters = halfWorldMeters * (bounds.getEast() - bounds.getWest()) / 180, meters = halfWorldMeters * (bounds.getEast() - bounds.getWest()) / 180,
pixelsPerMeter = map.getSize().x / meters, pixelsPerMeter = map.getSize().x / meters,
metersPerPixel = 1 / (92 * 39.3701); metersPerPixel = 1 / (92 * 39.3701);
return Math.round(1 / (pixelsPerMeter * metersPerPixel)); return Math.round(1 / (pixelsPerMeter * metersPerPixel));
} }

View file

@ -1,9 +1,9 @@
L.OSM.sidebar = function (selector) { L.OSM.sidebar = function (selector) {
var control = {}, var control = {},
sidebar = $(selector), sidebar = $(selector),
current = $(), current = $(),
currentButton = $(), currentButton = $(),
map; map;
control.addTo = function (_) { control.addTo = function (_) {
map = _; map = _;

View file

@ -1,72 +1,72 @@
L.OSM.Zoom = L.Control.extend({ L.OSM.Zoom = L.Control.extend({
options: { options: {
position: "topright" position: "topright"
}, },
onAdd: function (map) { onAdd: function (map) {
var zoomName = "zoom", var zoomName = "zoom",
container = L.DomUtil.create("div", zoomName); container = L.DomUtil.create("div", zoomName);
this._map = map; this._map = map;
this._zoomInButton = this._createButton( this._zoomInButton = this._createButton(
"", I18n.t("javascripts.map.zoom.in"), zoomName + "in", container, this._zoomIn, this); "", I18n.t("javascripts.map.zoom.in"), zoomName + "in", container, this._zoomIn, this);
this._zoomOutButton = this._createButton( this._zoomOutButton = this._createButton(
"", I18n.t("javascripts.map.zoom.out"), zoomName + "out", container, this._zoomOut, this); "", I18n.t("javascripts.map.zoom.out"), zoomName + "out", container, this._zoomOut, this);
map.on("zoomend zoomlevelschange", this._updateDisabled, this); map.on("zoomend zoomlevelschange", this._updateDisabled, this);
return container; return container;
}, },
onRemove: function (map) { onRemove: function (map) {
map.off("zoomend zoomlevelschange", this._updateDisabled, this); map.off("zoomend zoomlevelschange", this._updateDisabled, this);
}, },
_zoomIn: function (e) { _zoomIn: function (e) {
this._map.zoomIn(e.shiftKey ? 3 : 1); this._map.zoomIn(e.shiftKey ? 3 : 1);
}, },
_zoomOut: function (e) { _zoomOut: function (e) {
this._map.zoomOut(e.shiftKey ? 3 : 1); this._map.zoomOut(e.shiftKey ? 3 : 1);
}, },
_createButton: function (html, title, className, container, fn, context) { _createButton: function (html, title, className, container, fn, context) {
var link = L.DomUtil.create("a", "control-button " + className, container); var link = L.DomUtil.create("a", "control-button " + className, container);
link.innerHTML = html; link.innerHTML = html;
link.href = "#"; link.href = "#";
link.title = title; link.title = title;
L.DomUtil.create("span", "icon " + className, link); L.DomUtil.create("span", "icon " + className, link);
var stop = L.DomEvent.stopPropagation; var stop = L.DomEvent.stopPropagation;
L.DomEvent L.DomEvent
.on(link, "click", stop) .on(link, "click", stop)
.on(link, "mousedown", stop) .on(link, "mousedown", stop)
.on(link, "dblclick", stop) .on(link, "dblclick", stop)
.on(link, "click", L.DomEvent.preventDefault) .on(link, "click", L.DomEvent.preventDefault)
.on(link, "click", fn, context); .on(link, "click", fn, context);
return link; return link;
}, },
_updateDisabled: function () { _updateDisabled: function () {
var map = this._map, var map = this._map,
className = "disabled"; className = "disabled";
L.DomUtil.removeClass(this._zoomInButton, className); L.DomUtil.removeClass(this._zoomInButton, className);
L.DomUtil.removeClass(this._zoomOutButton, className); L.DomUtil.removeClass(this._zoomOutButton, className);
if (map._zoom === map.getMinZoom()) { if (map._zoom === map.getMinZoom()) {
L.DomUtil.addClass(this._zoomOutButton, className); L.DomUtil.addClass(this._zoomOutButton, className);
} }
if (map._zoom === map.getMaxZoom()) { if (map._zoom === map.getMaxZoom()) {
L.DomUtil.addClass(this._zoomInButton, className); L.DomUtil.addClass(this._zoomInButton, className);
} }
} }
}); });
L.OSM.zoom = function (options) { L.OSM.zoom = function (options) {
return new L.OSM.Zoom(options); return new L.OSM.Zoom(options);
}; };

View file

@ -96,8 +96,8 @@ OSM.Router = function (map, rts) {
}; };
var currentPath = window.location.pathname.replace(/(.)\/$/, "$1") + window.location.search, var currentPath = window.location.pathname.replace(/(.)\/$/, "$1") + window.location.search,
currentRoute = routes.recognize(currentPath), currentRoute = routes.recognize(currentPath),
currentHash = location.hash || OSM.formatHash(map); currentHash = location.hash || OSM.formatHash(map);
var router = {}; var router = {};
@ -105,7 +105,7 @@ OSM.Router = function (map, rts) {
$(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? if (!e.originalEvent.state) return; // Is it a real popstate event or just a hash change?
var path = window.location.pathname + window.location.search, var path = window.location.pathname + window.location.search,
route = routes.recognize(path); route = routes.recognize(path);
if (path === currentPath) return; if (path === currentPath) return;
currentRoute.run("unload", null, route === currentRoute); currentRoute.run("unload", null, route === currentRoute);
currentPath = path; currentPath = path;
@ -116,7 +116,7 @@ OSM.Router = function (map, rts) {
router.route = function (url) { router.route = function (url) {
var path = url.replace(/#.*/, ""), var path = url.replace(/#.*/, ""),
route = routes.recognize(path); route = routes.recognize(path);
if (!route) return false; if (!route) return false;
currentRoute.run("unload", null, route === currentRoute); currentRoute.run("unload", null, route === currentRoute);
var state = OSM.parseHash(url); var state = OSM.parseHash(url);

View file

@ -33,6 +33,13 @@
"eol-last": "error", "eol-last": "error",
"eqeqeq": ["error", "smart"], "eqeqeq": ["error", "smart"],
"func-call-spacing": "error", "func-call-spacing": "error",
"indent": ["error", 2, {
"SwitchCase": 1,
"VariableDeclarator": "first",
"FunctionDeclaration": { "parameters": "first" },
"FunctionExpression": { "parameters": "first" },
"CallExpression": { "arguments": "first" }
}],
"key-spacing": "error", "key-spacing": "error",
"keyword-spacing": "error", "keyword-spacing": "error",
"no-alert": "warn", "no-alert": "warn",