[openstreetmap/openstreetmap-website] Split directions engine select into modes and providers (PR #5652)

Tom Hughes notifications at github.com
Tue Feb 25 20:28:15 UTC 2025


@tomhughes commented on this pull request.



> -    });
-  }
-
-  function setEngine(index) {
-    chosenEngine = engines[index];
-    select.val(index);
+  function setEngine(id) {
+    const engines = OSM.Directions.engines;
+    const desired = engines.find(engine => engine.id() === id);
+    if (!desired || (chosenEngine && chosenEngine.id() === id)) return;
+    chosenEngine = desired;
+
+    const modes = engines
+      .filter(engine => engine.provider === chosenEngine.provider)
+      .map(engine => engine.mode)
+      .sort((a, b) => I18n.t("javascripts.directions.modes." + a).localeCompare(I18n.t("javascripts.directions.modes." + b)));

I'm not sure why the current code sorts them but it seems wrong to me - there's no logical reason why the order in which they are shown should depend on the language.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5652#discussion_r1970496959
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5652/review/2642386588 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250225/ddfe4600/attachment.htm>


More information about the rails-dev mailing list