From cd71949c8288e7e930e35a2a6ac21ce02bee1e77 Mon Sep 17 00:00:00 2001 From: Manuel Weiser Date: Mon, 10 Mar 2025 17:33:47 +0100 Subject: [PATCH] refactor length calculation to convert total length to meters before formatting --- html/spoolman.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/html/spoolman.js b/html/spoolman.js index cbc9c67..b0ffe66 100644 --- a/html/spoolman.js +++ b/html/spoolman.js @@ -86,10 +86,10 @@ function populateVendorDropdown(data, selectedSmId = null) { }); // Nach der Schleife: Formatierung der Gesamtlänge - console.log("Total Length: ", totalLength); - const formattedLength = totalLength > 1000 - ? (totalLength / 1000).toFixed(2) + " km" - : totalLength.toFixed(2) + " m"; + const lengthInM = totalLength / 1000; // erst in m umrechnen + const formattedLength = lengthInM > 1000 + ? (lengthInM / 1000).toFixed(2) + " km" + : lengthInM.toFixed(2) + " m"; // Formatierung des Gesamtgewichts (von g zu kg zu t) const weightInKg = totalWeight / 1000; // erst in kg umrechnen