]> git.openstreetmap.org Git - rails.git/commitdiff
Enable a number of eslint style rules
authorTom Hughes <tom@compton.nu>
Sun, 7 Apr 2019 16:02:39 +0000 (17:02 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 7 Apr 2019 16:02:39 +0000 (17:02 +0100)
28 files changed:
app/assets/javascripts/application.js
app/assets/javascripts/diary_entry.js
app/assets/javascripts/fixthemap.js
app/assets/javascripts/id.js
app/assets/javascripts/index.js
app/assets/javascripts/index/browse.js
app/assets/javascripts/index/changeset.js
app/assets/javascripts/index/contextmenu.js
app/assets/javascripts/index/directions.js
app/assets/javascripts/index/directions/fossgis.js
app/assets/javascripts/index/directions/graphhopper.js
app/assets/javascripts/index/export.js
app/assets/javascripts/index/history.js
app/assets/javascripts/index/new_note.js
app/assets/javascripts/index/note.js
app/assets/javascripts/index/notes.js
app/assets/javascripts/index/query.js
app/assets/javascripts/index/search.js
app/assets/javascripts/leaflet.layers.js
app/assets/javascripts/leaflet.map.js
app/assets/javascripts/leaflet.share.js
app/assets/javascripts/leaflet.sidebar.js
app/assets/javascripts/login.js
app/assets/javascripts/oauth.js
app/assets/javascripts/router.js
app/assets/javascripts/user.js
app/assets/javascripts/welcome.js
config/eslint.json

index d73b3c69c1605a67c94315cfd1e0955735ddc7f2..4a310f22bb8856778e85481e834f7f9fbe6de1dc 100644 (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");
   });
 
index 73a179ba9e00bc9f3edad12da9241180d300cdbc..625d43a5228f0b07a391f988a43cae3327364e67 100644 (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"));
     }
 
index 9bfb01ad56e3e9e73a3ae9332850e6059b0f1ed6..47ba9baf4da556ea4b30dfd38d173575dec960f3 100644 (file)
@@ -1,4 +1,4 @@
-$(document).ready(function() {
+$(document).ready(function () {
   var params = OSM.params();
 
   var url = "/note/new";
index fbe810d28922a7ec689ec23c1bc622686192eafa..0aae749f7d2fbece85bb2713d853d8aab5ec04dc 100644 (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));
index cce07f3240b399e943f14bf7f057d3d53d062ad9..6228b2376cd58fe81093f5a4cf9924482fc07eed 100644 (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();
+    }
   });
 });
index c840ecdfaf6ddebb5017bc255dd70af8b7aa908c..6309444110a1206f7f22e57a2d54f02c3d5422ee 100644 (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);
 
index b670bd28925249566a75308b9a735d3f00cf0dcc..5ff8edc7103adc5ffc6b58554461d635e2344456 100644 (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();
   };
 
index 080a4de72b14691b5328a8b12976f061901b23db..e3e30ce6bbe859a643f2064bfea6c90c5b4a461a 100644 (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);
   };
index 28d436a9647e06b358b11611c431685edaf8881b..4283ef5aa7ef5ca7f57208fcc7fab8b4dd15e604 100644 (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");
index 6033e511b2a35b15437ba65a7c358588c6141d9b..8e5e8e621d6d8b194e9ecc7f254c43287cb077ab 100644 (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;
         });
 
index 83f266accc9d1b1b59af0d4dd8fb2e9322fbf908..6bd430c06021612ccb086a8b58b6c14f97a9d6af 100644 (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,
index 48e950b2137870f88e4aac912781cf3b94d17a70..67530370dc525cd9ca026545e2a31e121f56ba3f 100644 (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);
index 4f03de06dc35b95070d78f8e5c55d24d30aca8dc..a0c68e84017b5a9bc5e95aa70658457530e5dc84 100644 (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);
 
index 3111a579fa465c5f08c24d41a8cbb3e5784853cd..7196a779bf5ef2d1020c1e51c41d6c8c5f9a211d 100644 (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();
index fadaadfd80166cfe1670d957648411f3af329148..52bb1c90958c0aefcdcf87caab6e5d2019cf7664 100644 (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 });
       });
     }
   }
index 1eb61f8eba2898d394ff23492e15d4bcd2d94ebd..4890a2687d1a86a69811ad46d54a1a870227c1a4 100644 (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;
   };
 
index 407e088e5a62b48ffbd99f9fc3db0f87db271ac7..6869e19f63835f44366e1a68d6ba4a18487b2d7a 100644 (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();
     }
index 17945436e5af22872d25275856ca0cd4c4a879ff..fa9546f4e27fee974c202a10f20e2588e5d48ebc 100644 (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);
index 974962ffd02b93de29bebb6230b812aa55b996b7..b12c0c89d79bc56500a445cd242a1f223692e4ef 100644 (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);
 
index c8377226a0b725b9564905c0396817818e7426fb..d3588ac53c22d03eb46afd40da9b36c831e85150 100644 (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];
   }
index bca8e5c6a6d7ba5d5db43b1e383bcf3f4de54860..69100e4202c3c9a9ccdca6884a4aa95e697a62db 100644 (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];
       });
     }
index 240e79a5095f16e957bc640df041622c382b5ec9..bb046f99ad13ae029c840912e7a7be611494a365 100644 (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()
index 3496587b49848cadbd8d7f96c40cf70db970f905..853db34a978b22e2ce368d5c0990250c29d7ae13 100644 (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(),
index cb448d826759da070afe13c6976435e132efefbd..411f7fc349194a599b39f6579559ef25a3b73841 100644 (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);
index c42e703c58aa036cfdf2c8e824a3385e460311cb..08a6c7268579f65ca341de933c02ca66c2336964 100644 (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 || {});
   };
index 73bb2406ec2f0f680a8a685c674b6e4877b3a87e..f898455b5815feab5fc2e0c76849687f80f829aa 100644 (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);
         }
       });
index c83d153dabf93b9f4329e086fe139fed7255af97..35a1fdc4bdfc6a864e05ea52a2f5a37859f05daf 100644 (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");
 
index c207e35951b3c79fc9226cfef5d8a6e9f91a438f..8790b5edf88b39266b05313b11628f42ddf63f4f 100644 (file)
   },
   "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",
     "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",
     "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"