]> git.openstreetmap.org Git - rails.git/commitdiff
Fix issues found by eslint
authorTom Hughes <tom@compton.nu>
Mon, 1 Apr 2019 20:33:33 +0000 (21:33 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 1 Apr 2019 21:03:39 +0000 (22:03 +0100)
app/assets/javascripts/index.js
app/assets/javascripts/index/directions.js
app/assets/javascripts/index/note.js
app/assets/javascripts/index/search.js
app/assets/javascripts/piwik.js
app/assets/javascripts/richtext.js

index e8e566f53a2ca698ae09000cb73d54118282fd8d..d1527207ff6bd7a7e2a16b1cd3fea3a702d9ecc5 100644 (file)
 $(document).ready(function () {
   var loaderTimeout;
 
 $(document).ready(function () {
   var loaderTimeout;
 
+  var map = new L.OSM.Map("map", {
+    zoomControl: false,
+    layerControl: false,
+    contextmenu: true
+  });
+
   OSM.loadSidebarContent = function(path, callback) {
     map.setSidebarOverlaid(false);
 
   OSM.loadSidebarContent = function(path, callback) {
     map.setSidebarOverlaid(false);
 
@@ -78,12 +84,6 @@ $(document).ready(function () {
 
   var params = OSM.mapParams();
 
 
   var params = OSM.mapParams();
 
-  var map = new L.OSM.Map("map", {
-    zoomControl: false,
-    layerControl: false,
-    contextmenu: true
-  });
-
   map.attributionControl.setPrefix('');
 
   map.updateLayers(params.layers);
   map.attributionControl.setPrefix('');
 
   map.updateLayers(params.layers);
index bdba41ec25c2aca44f7c439a639abda38f036d27..dd408debcf1301fd0d68234283db28e5f158c91d 100644 (file)
@@ -28,6 +28,20 @@ OSM.Directions = function (map) {
   var expiry = new Date();
   expiry.setYear(expiry.getFullYear() + 10);
 
   var expiry = new Date();
   expiry.setYear(expiry.getFullYear() + 10);
 
+  var engines = OSM.Directions.engines;
+
+  engines.sort(function (a, b) {
+    a = I18n.t('javascripts.directions.engines.' + a.id);
+    b = I18n.t('javascripts.directions.engines.' + b.id);
+    return a.localeCompare(b);
+  });
+
+  var select = $('select.routing_engines');
+
+  engines.forEach(function(engine, i) {
+    select.append("<option value='" + i + "'>" + I18n.t('javascripts.directions.engines.' + engine.id) + "</option>");
+  });
+
   function Endpoint(input, iconUrl) {
     var endpoint = {};
 
   function Endpoint(input, iconUrl) {
     var endpoint = {};
 
@@ -60,7 +74,7 @@ OSM.Directions = function (map) {
 
     input.on("change", function (e) {
       awaitingGeocode = true;
 
     input.on("change", function (e) {
       awaitingGeocode = true;
-      
+
       // make text the same in both text boxes
       var value = e.target.value;
       endpoint.setValue(value);
       // make text the same in both text boxes
       var value = e.target.value;
       endpoint.setValue(value);
@@ -245,7 +259,6 @@ OSM.Directions = function (map) {
         .html(html);
 
       // Add each row
         .html(html);
 
       // Add each row
-      var cumulative = 0;
       route.steps.forEach(function (step) {
         var ll        = step[0],
           direction   = step[1],
       route.steps.forEach(function (step) {
         var ll        = step[0],
           direction   = step[1],
@@ -253,8 +266,6 @@ OSM.Directions = function (map) {
           dist        = step[3],
           lineseg     = step[4];
 
           dist        = step[3],
           lineseg     = step[4];
 
-        cumulative += dist;
-
         if (dist < 5) {
           dist = "";
         } else if (dist < 200) {
         if (dist < 5) {
           dist = "";
         } else if (dist < 200) {
@@ -304,20 +315,6 @@ OSM.Directions = function (map) {
     });
   }
 
     });
   }
 
-  var engines = OSM.Directions.engines;
-
-  engines.sort(function (a, b) {
-    a = I18n.t('javascripts.directions.engines.' + a.id);
-    b = I18n.t('javascripts.directions.engines.' + b.id);
-    return a.localeCompare(b);
-  });
-
-  var select = $('select.routing_engines');
-
-  engines.forEach(function(engine, i) {
-    select.append("<option value='" + i + "'>" + I18n.t('javascripts.directions.engines.' + engine.id) + "</option>");
-  });
-
   var chosenEngineIndex = findEngine('fossgis_osrm_car');
   if ($.cookie('_osm_directions_engine')) {
     chosenEngineIndex = findEngine($.cookie('_osm_directions_engine'));
   var chosenEngineIndex = findEngine('fossgis_osrm_car');
   if ($.cookie('_osm_directions_engine')) {
     chosenEngineIndex = findEngine($.cookie('_osm_directions_engine'));
index 3973420bdd3d3536682aa0b87b6720c65b7e9874..85267ab93ed5d53f9c47fadf4123cf37f01c8a21 100644 (file)
@@ -40,7 +40,7 @@ OSM.Note = function (map) {
       initialize(function() {
         var data = $('.details').data(),
           latLng = L.latLng(data.coordinates.split(','));
       initialize(function() {
         var data = $('.details').data(),
           latLng = L.latLng(data.coordinates.split(','));
-        if (!map.getBounds().contains(latLng)) moveToNote();        
+        if (!map.getBounds().contains(latLng)) moveToNote();
       });
     });
   };
       });
     });
   };
index ea6140e582db78dea993eccdbde6eb1659124bb9..6ca145c0325f9c8d4148a3635200f905380be46b 100644 (file)
@@ -55,6 +55,8 @@ OSM.Search = function(map) {
       });
     });
 
       });
     });
 
+  var markers = L.layerGroup().addTo(map);
+
   function clickSearchMore(e) {
     e.preventDefault();
     e.stopPropagation();
   function clickSearchMore(e) {
     e.preventDefault();
     e.stopPropagation();
@@ -115,8 +117,6 @@ OSM.Search = function(map) {
     e.stopPropagation();
   }
 
     e.stopPropagation();
   }
 
-  var markers = L.layerGroup().addTo(map);
-
   var page = {};
 
   page.pushstate = page.popstate = function(path) {
   var page = {};
 
   page.pushstate = page.popstate = function(path) {
index 19b5619a2558cef99ab7deec512841dd487d9eff..5353a99ac199609cd763903e953083625501cdc0 100644 (file)
@@ -9,14 +9,14 @@ if (OSM.PIWIK) {
       cache: true,
       success: function () {
         piwikTracker = Piwik.getTracker(base + "piwik.php", OSM.PIWIK.site);
       cache: true,
       success: function () {
         piwikTracker = Piwik.getTracker(base + "piwik.php", OSM.PIWIK.site);
-      
+
         if (OSM.user) {
           piwikTracker.setUserId(OSM.user.toString());
         }
 
         piwikTracker.trackPageView();
         piwikTracker.enableLinkTracking();
         if (OSM.user) {
           piwikTracker.setUserId(OSM.user.toString());
         }
 
         piwikTracker.trackPageView();
         piwikTracker.enableLinkTracking();
-      
+
         $("meta[name=piwik-goal]").each(function () {
           piwikTracker.trackGoal($(this).attr("content"));
         });
         $("meta[name=piwik-goal]").each(function () {
           piwikTracker.trackGoal($(this).attr("content"));
         });
index a5323bc0774c3adcd81ba28a191c27c88ffcce0f..ea2efcfadc33b74e5b7f11a4988ed47ada2e0f68 100644 (file)
@@ -2,12 +2,12 @@ $(document).ready(function () {
   /* Hide the preview panes */
   $(".richtext_preview").hide();
 
   /* Hide the preview panes */
   $(".richtext_preview").hide();
 
-  /* 
+  /*
    * When the text in an edit pane is changed, clear the contents of
    * the associated preview pne so that it will be regenerated when
    * the user next switches to it.
    */
    * When the text in an edit pane is changed, clear the contents of
    * the associated preview pne so that it will be regenerated when
    * the user next switches to it.
    */
-  $(".richtext_content textarea").change(function () { 
+  $(".richtext_content textarea").change(function () {
     $(this).parents(".richtext_container").find(".richtext_preview").empty();
   });
 
     $(this).parents(".richtext_container").find(".richtext_preview").empty();
   });