From 7d6b090815c622e1d63c177510ac3013ff576fcb Mon Sep 17 00:00:00 2001 From: Marwin Hochfelsner <50826859+hlfan@users.noreply.github.com> Date: Mon, 22 Jun 2026 03:09:41 +0200 Subject: [PATCH] Collapse OSM.Directions namespace --- app/assets/javascripts/index_modules/directions.js | 2 +- app/assets/javascripts/index_modules/directions/engines.js | 6 +++--- .../index_modules/directions/engines/fossgis_osrm.js | 6 +++--- .../index_modules/directions/engines/fossgis_valhalla.js | 6 +++--- .../index_modules/directions/engines/graphhopper.js | 6 +++--- test/system/directions_test.rb | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/index_modules/directions.js b/app/assets/javascripts/index_modules/directions.js index d70233f65..e38d4ab81 100644 --- a/app/assets/javascripts/index_modules/directions.js +++ b/app/assets/javascripts/index_modules/directions.js @@ -59,7 +59,7 @@ export default function (map) { }); function setEngine(id) { - const engines = OSM.Directions.engines; + const engines = OSM.directionsEngines; const desired = engines.find(engine => engine.id === id); if (!desired || (chosenEngine && chosenEngine.id === id)) return; diff --git a/app/assets/javascripts/index_modules/directions/engines.js b/app/assets/javascripts/index_modules/directions/engines.js index d7b323245..9c9b69fb9 100644 --- a/app/assets/javascripts/index_modules/directions/engines.js +++ b/app/assets/javascripts/index_modules/directions/engines.js @@ -1,11 +1,11 @@ //= require_self //= require_tree ./engines -OSM.Directions = { engines: [] }; +OSM.directionsEngines = []; -OSM.Directions.addEngine = function (engine, supportsHTTPS) { +OSM.directionsEngines.add = function (engine, supportsHTTPS) { if (location.protocol === "http:" || supportsHTTPS) { engine.id = engine.provider + "_" + engine.mode; - OSM.Directions.engines.push(engine); + OSM.directionsEngines.push(engine); } }; diff --git a/app/assets/javascripts/index_modules/directions/engines/fossgis_osrm.js b/app/assets/javascripts/index_modules/directions/engines/fossgis_osrm.js index 61227c5a0..04002170c 100644 --- a/app/assets/javascripts/index_modules/directions/engines/fossgis_osrm.js +++ b/app/assets/javascripts/index_modules/directions/engines/fossgis_osrm.js @@ -212,7 +212,7 @@ }; } - OSM.Directions.addEngine(new FOSSGISOSRMEngine("car", "car", "0"), true); - OSM.Directions.addEngine(new FOSSGISOSRMEngine("bicycle", "bike", "1"), true); - OSM.Directions.addEngine(new FOSSGISOSRMEngine("foot", "foot", "2"), true); + OSM.directionsEngines.add(new FOSSGISOSRMEngine("car", "car", "0"), true); + OSM.directionsEngines.add(new FOSSGISOSRMEngine("bicycle", "bike", "1"), true); + OSM.directionsEngines.add(new FOSSGISOSRMEngine("foot", "foot", "2"), true); }()); diff --git a/app/assets/javascripts/index_modules/directions/engines/fossgis_valhalla.js b/app/assets/javascripts/index_modules/directions/engines/fossgis_valhalla.js index b949d40f2..b78aaf558 100644 --- a/app/assets/javascripts/index_modules/directions/engines/fossgis_valhalla.js +++ b/app/assets/javascripts/index_modules/directions/engines/fossgis_valhalla.js @@ -101,7 +101,7 @@ }; } - OSM.Directions.addEngine(new FOSSGISValhallaEngine("car", "auto", "car"), true); - OSM.Directions.addEngine(new FOSSGISValhallaEngine("bicycle", "bicycle", "bicycle"), true); - OSM.Directions.addEngine(new FOSSGISValhallaEngine("foot", "pedestrian", "pedestrian"), true); + OSM.directionsEngines.add(new FOSSGISValhallaEngine("car", "auto", "car"), true); + OSM.directionsEngines.add(new FOSSGISValhallaEngine("bicycle", "bicycle", "bicycle"), true); + OSM.directionsEngines.add(new FOSSGISValhallaEngine("foot", "pedestrian", "pedestrian"), true); }()); diff --git a/app/assets/javascripts/index_modules/directions/engines/graphhopper.js b/app/assets/javascripts/index_modules/directions/engines/graphhopper.js index c007f729d..942cecb3b 100644 --- a/app/assets/javascripts/index_modules/directions/engines/graphhopper.js +++ b/app/assets/javascripts/index_modules/directions/engines/graphhopper.js @@ -80,7 +80,7 @@ }; } - OSM.Directions.addEngine(new GraphHopperEngine("car", "car", "car"), true); - OSM.Directions.addEngine(new GraphHopperEngine("bicycle", "bike", "bike"), true); - OSM.Directions.addEngine(new GraphHopperEngine("foot", "foot", "foot"), true); + OSM.directionsEngines.add(new GraphHopperEngine("car", "car", "car"), true); + OSM.directionsEngines.add(new GraphHopperEngine("bicycle", "bike", "bike"), true); + OSM.directionsEngines.add(new GraphHopperEngine("foot", "foot", "foot"), true); }()); diff --git a/test/system/directions_test.rb b/test/system/directions_test.rb index 6b42abe08..5fd9cb899 100644 --- a/test/system/directions_test.rb +++ b/test/system/directions_test.rb @@ -88,7 +88,7 @@ class DirectionsSystemTest < ApplicationSystemTestCase def stub_routing(callback_code) execute_script <<~SCRIPT $(() => { - for (const engine of OSM.Directions.engines) { + for (const engine of OSM.directionsEngines) { engine.getRoute = function(points, signal) { #{callback_code} }; -- 2.47.3