From 4dd2cc9d9ef9586583ab466040d36302eb29c127 Mon Sep 17 00:00:00 2001 From: Derf Null Date: Sun, 2 Jul 2023 10:48:34 +0200 Subject: show hours and minutes until arrival, not just minutes --- public/static/js/travelynx-actions.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'public') diff --git a/public/static/js/travelynx-actions.js b/public/static/js/travelynx-actions.js index a9e8218..91b0009 100644 --- a/public/static/js/travelynx-actions.js +++ b/public/static/js/travelynx-actions.js @@ -41,12 +41,19 @@ function upd_journey_data() { }); } function upd_countdown() { - var now = Date.now() / 1000; + const now = Date.now() / 1000; if (j_departure > now) { $('.countdown').text('Abfahrt in ' + Math.round((j_departure - now)/60) + ' Minuten'); } else if (j_arrival > 0) { if (j_arrival > now) { - $('.countdown').text('Ankunft in ' + Math.round((j_arrival - now)/60) + ' Minuten'); + var diff = Math.round((j_arrival - now)/60); + if (diff >= 120) { + $('.countdown').text('Ankunft in ' + Math.floor(diff/60) + ' Stunden und ' + (diff%60) + ' Minuten'); + } else if (diff >= 60) { + $('.countdown').text('Ankunft in 1 Stunde und ' + (diff%60) + ' Minuten'); + } else { + $('.countdown').text('Ankunft in ' + diff + ' Minuten'); + } } else { $('.countdown').text('Ziel erreicht'); } -- cgit v1.2.3