ctucx.git: trainsearch

web based trip-planner, fork of https://cyberchaos.dev/yuka/trainsearch

commit 6287fea466b5227140d46f06ef3fec26a0522dbf
parent 1c317833004621997646fc162ab4254aa6ab69bb
Author: stuebinm <stuebinm@disroot.org>
Date: Wed, 24 May 2023 21:37:48 +0200

trip view: use planned departure if departure=null

this seems to happen in case the first stop was cancelled. The same
might also happen to the arrival time if the last stop is cancelled, but
I haven't found a trip where that is the case to test.
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/languages.js b/src/languages.js
@@ -15,6 +15,7 @@ export const languages = {
 		'de':                 'Deutsch',
 		'departure':          'Abfahrt',
 		'duration':           'Dauer',
+		'planned':            'geplant',
 		'dzug':               'D-Zug',
 		'en':                 'Englisch',
 		'ferry':              'Fähre',

@@ -82,6 +83,7 @@ export const languages = {
 		'de':                 'Duits',
 		'departure':          'Vertrek',
 		'duration':           'Duur',
+		'planned':            'gepland',
 		'dzug':               'Sneltrein',
 		'en':                 'Engels',
 		'ferry':              'Veerboot',

@@ -149,6 +151,7 @@ export const languages = {
 		'de':                'German',
 		'departure':         'Departure',
 		'duration':          'Duration',
+		'planned':           'planned',
 		'dzug':              'D-Zug',
 		'en':                'English',
 		'ferry':             'Ferry',
diff --git a/src/tripView.js b/src/tripView.js
@@ -100,8 +100,8 @@ const tripTemplate = (data, profile) => {
 										Train type: ${data.line.trainType}
 									</div>
 								` : ''}
-								<div class="train-detail">
-									${t('duration')}: ${formatDuration(data.arrival - data.departure)}
+								<div class="train-detail ${data.cancelled ? 'cancelled' : ''}">
+									${t('duration')}: ${formatDuration(data.arrival - (data.departure ? data.departure : data.plannedDeparture))} ${data.departure ? '' : ('(' + t('planned') + ')')}
 								</div>
 								${data.loadFactor ? html`
 									<div class="train-detail">