From: Anton Khorev Date: Sun, 9 Mar 2025 13:30:49 +0000 (+0300) Subject: Rename distance formatting functions X-Git-Tag: live~26^2~1 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/a62cf867cf9b39d1ef73939496748984b8fe66c0?ds=inline;hp=--cc Rename distance formatting functions --- a62cf867cf9b39d1ef73939496748984b8fe66c0 diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index a679d945f..eb1b9d0df 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -70,7 +70,7 @@ OSM.Directions = function (map) { OSM.router.route("/" + OSM.formatHash(map)); }); - function formatDistance(m) { + function formatTotalDistance(m) { if (m < 1000) { return I18n.t("javascripts.directions.distance_m", { distance: Math.round(m) }); } else if (m < 10000) { @@ -80,17 +80,17 @@ OSM.Directions = function (map) { } } - function getDistText(dist) { - if (dist < 5) { + function formatStepDistance(m) { + if (m < 5) { return ""; - } else if (dist < 200) { - return String(Math.round(dist / 10) * 10) + "m"; - } else if (dist < 1500) { - return String(Math.round(dist / 100) * 100) + "m"; - } else if (dist < 5000) { - return String(Math.round(dist / 100) / 10) + "km"; + } else if (m < 200) { + return String(Math.round(m / 10) * 10) + "m"; + } else if (m < 1500) { + return String(Math.round(m / 100) * 100) + "m"; + } else if (m < 5000) { + return String(Math.round(m / 100) / 10) + "km"; } else { - return String(Math.round(dist / 1000)) + "km"; + return String(Math.round(m / 1000)) + "km"; } } @@ -164,7 +164,7 @@ OSM.Directions = function (map) { } const distanceText = $("

").append( - I18n.t("javascripts.directions.distance") + ": " + formatDistance(route.distance) + ". " + + I18n.t("javascripts.directions.distance") + ": " + formatTotalDistance(route.distance) + ". " + I18n.t("javascripts.directions.time") + ": " + formatTime(route.time) + "."); if (typeof route.ascend !== "undefined" && typeof route.descend !== "undefined") { distanceText.append( @@ -194,7 +194,7 @@ OSM.Directions = function (map) { row.append(""); } row.append("" + instruction); - row.append("" + getDistText(dist)); + row.append("" + formatStepDistance(dist)); row.on("click", function () { popup