diff options
author | Derf Null <derf@finalrewind.org> | 2023-07-02 10:48:34 +0200 |
---|---|---|
committer | Derf Null <derf@finalrewind.org> | 2023-07-02 10:48:34 +0200 |
commit | 4dd2cc9d9ef9586583ab466040d36302eb29c127 (patch) | |
tree | 0bf5ac7ccf7d508ef5ca007f4d6a15f009d6e326 /public | |
parent | 66e8dcb9254ee172f3aa694526800e399f1808d5 (diff) |
show hours and minutes until arrival, not just minutes
Diffstat (limited to 'public')
-rw-r--r-- | public/static/js/travelynx-actions.js | 11 |
1 files changed, 9 insertions, 2 deletions
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'); } |