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

Anton Khorev notifications at github.com
Thu Feb 20 05:17:02 UTC 2025


@AntonKhorev commented on this pull request.



> +    for (const mode of new Set(modes)) {
+      modeGroup.append(`<input type="radio" class="btn-check" name="modes" id="${mode}" autocomplete="off">`);
+      modeGroup.append(`<label class="btn btn-outline-secondary px-2" for="${mode}" title="${
+        I18n.t("javascripts.directions.modes." + mode)
+      }"><svg class="d-block" width="16" height="16" fill="currentColor"><path d="${modeIconPaths[mode]}"></path></svg></label>`);
+    }
+    $(".routing_modes input#" + chosenEngine.mode).prop("checked", true);
+
+    const providers = engines
+      .filter(engine => engine.mode === chosenEngine.mode)
+      .map(engine => engine.provider)
+      .sort((a, b) => I18n.t("javascripts.directions.providers." + a).localeCompare(I18n.t("javascripts.directions.providers." + b)));
+    select.html("");
+    for (const provider of new Set(providers)) {
+      select.append(`<option value="${provider}">${
+        I18n.t("javascripts.directions.providers." + provider)

I know this *let's interpolate unescaped html from external source* was in the original code, but you don't have to replicate it.

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

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


More information about the rails-dev mailing list