From: Tom Hughes Date: Mon, 1 Apr 2019 20:33:33 +0000 (+0100) Subject: Fix issues found by eslint X-Git-Tag: live~2605^2 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/1f13321a60239881f7016044b79e9a4d58045e30 Fix issues found by eslint --- diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index e8e566f53..d1527207f 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -25,6 +25,12 @@ $(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); @@ -78,12 +84,6 @@ $(document).ready(function () { var params = OSM.mapParams(); - var map = new L.OSM.Map("map", { - zoomControl: false, - layerControl: false, - contextmenu: true - }); - map.attributionControl.setPrefix(''); map.updateLayers(params.layers); diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index bdba41ec2..dd408debc 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -28,6 +28,20 @@ OSM.Directions = function (map) { 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(""); + }); + function Endpoint(input, iconUrl) { var endpoint = {}; @@ -60,7 +74,7 @@ OSM.Directions = function (map) { input.on("change", function (e) { awaitingGeocode = true; - + // 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 - var cumulative = 0; 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]; - cumulative += dist; - 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(""); - }); - var chosenEngineIndex = findEngine('fossgis_osrm_car'); if ($.cookie('_osm_directions_engine')) { chosenEngineIndex = findEngine($.cookie('_osm_directions_engine')); diff --git a/app/assets/javascripts/index/note.js b/app/assets/javascripts/index/note.js index 3973420bd..85267ab93 100644 --- a/app/assets/javascripts/index/note.js +++ b/app/assets/javascripts/index/note.js @@ -40,7 +40,7 @@ OSM.Note = function (map) { initialize(function() { var data = $('.details').data(), latLng = L.latLng(data.coordinates.split(',')); - if (!map.getBounds().contains(latLng)) moveToNote(); + if (!map.getBounds().contains(latLng)) moveToNote(); }); }); }; diff --git a/app/assets/javascripts/index/search.js b/app/assets/javascripts/index/search.js index ea6140e58..6ca145c03 100644 --- a/app/assets/javascripts/index/search.js +++ b/app/assets/javascripts/index/search.js @@ -55,6 +55,8 @@ OSM.Search = function(map) { }); }); + var markers = L.layerGroup().addTo(map); + function clickSearchMore(e) { e.preventDefault(); e.stopPropagation(); @@ -115,8 +117,6 @@ OSM.Search = function(map) { e.stopPropagation(); } - var markers = L.layerGroup().addTo(map); - var page = {}; page.pushstate = page.popstate = function(path) { diff --git a/app/assets/javascripts/piwik.js b/app/assets/javascripts/piwik.js index 19b5619a2..5353a99ac 100644 --- a/app/assets/javascripts/piwik.js +++ b/app/assets/javascripts/piwik.js @@ -9,14 +9,14 @@ if (OSM.PIWIK) { 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(); - + $("meta[name=piwik-goal]").each(function () { piwikTracker.trackGoal($(this).attr("content")); }); diff --git a/app/assets/javascripts/richtext.js b/app/assets/javascripts/richtext.js index a5323bc07..ea2efcfad 100644 --- a/app/assets/javascripts/richtext.js +++ b/app/assets/javascripts/richtext.js @@ -2,12 +2,12 @@ $(document).ready(function () { /* 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. */ - $(".richtext_content textarea").change(function () { + $(".richtext_content textarea").change(function () { $(this).parents(".richtext_container").find(".richtext_preview").empty(); });