From: Anton Khorev Date: Wed, 9 Apr 2025 14:39:27 +0000 (+0300) Subject: Use for loop to write directions table X-Git-Tag: live~61^2~3 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/8cf9c691f28ab0319c8eb6585b3ed6974d1fb8e1?ds=sidebyside;hp=-c Use for loop to write directions table Reverts part of 2af72b2e6f4e4c1c0775f16f102f50a59bdeb0c3 --- 8cf9c691f28ab0319c8eb6585b3ed6974d1fb8e1 diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index 45ff960e2..d2d23c545 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -184,8 +184,9 @@ OSM.Directions = function (map) { ); // Add each row - turnByTurnTable.append(route.steps.map(([direction, instruction, dist, lineseg], i) => { - const row = $(""); + for (const [i, [direction, instruction, dist, lineseg]] of route.steps.entries()) { + const row = $("").appendTo(turnByTurnTable); + if (direction) { row.append(""); } else { @@ -208,9 +209,7 @@ OSM.Directions = function (map) { }, function () { map.removeLayer(highlight); }); - - return row; - })); + } const blob = new Blob([JSON.stringify(polyline.toGeoJSON())], { type: "application/json" }); URL.revokeObjectURL(downloadURL);