From 4fc48f9a9218421a6b765499512764d4fcb86086 Mon Sep 17 00:00:00 2001 From: "Leah (ctucx)" Date: Fri, 22 Jan 2021 16:22:01 +0100 Subject: [PATCH] journeyView: add link to marudor --- client/js/journeyView.js | 54 ++++++++++++++++++++++++++-------------- client/style.css | 10 +++++++- 2 files changed, 45 insertions(+), 19 deletions(-) diff --git a/client/js/journeyView.js b/client/js/journeyView.js index c10a032..e504018 100644 --- a/client/js/journeyView.js +++ b/client/js/journeyView.js @@ -44,49 +44,67 @@ const remarksTemplate = ([type, remarks]) => !!remarks.length ? html` showRemarksModal(type, remarks)}> ` : ''; -const legTemplate = (element) => { - const allRemarks = element.remarks || []; +const legTemplate = (leg) => { + const allRemarks = leg.remarks || []; const remarks = { "status": allRemarks.filter(r => r.type === 'status'), "hint": allRemarks.filter(r => r.type === 'hint'), "other": allRemarks.filter(r => r.type !== 'status' && r.type !== 'hint'), }; + let hasMarudorURL = false; + let marudorUrl = ''; + + if (!leg.isWalking && !leg.isTransfer && !leg.isChange) { + if (leg.line.product == "nationalExp" || leg.line.product == "national" || leg.line.product == "regionalExp" || leg.line.product == "regional") { + hasMarudorURL = true; + } + + if (!leg.line.additionalName) { + marudorUrl = 'https://marudor.de/details/' + leg.line.name + '/' + (leg.departure.plannedTime*1000) + } else { + marudorUrl = 'https://marudor.de/details/' + leg.line.additionalName + "/" + (leg.departure.plannedTime*1000) + } + } + return html` - ${element.isWalking ? html` -

${t('walkinfo', [parseName(element.arrival.point), element.distance])}

- ` : element.isTransfer ? html` -

${t('transferinfo', [parseName(element.arrival.point)])}

- ` : element.isChange ? html` -

${t('changeinfo', [formatDuration(element.duration)])}

+ ${leg.isWalking ? html` +

${t('walkinfo', [parseName(leg.arrival.point), leg.distance])}

+ ` : leg.isTransfer ? html` +

${t('transferinfo', [parseName(leg.arrival.point)])}

+ ` : leg.isChange ? html` +

${t('changeinfo', [formatDuration(leg.duration)])}

` : html`
@@ -99,7 +117,7 @@ const legTemplate = (element) => { - ${element.stopovers.map(stop => html` + ${leg.stopovers.map(stop => html` {location.href = "https://marudor.de/"+stop.stop.id+"?searchType=hafas"}}> diff --git a/client/style.css b/client/style.css index 04fb040..bc0cacb 100755 --- a/client/style.css +++ b/client/style.css @@ -367,7 +367,6 @@ tbody tr:hover td { } .journeys table a, -.journey table a, .journey table span { padding: 5px 3px; display: flex; @@ -378,6 +377,15 @@ tbody tr:hover td { color: black; } +.journey table a { + padding: 5px 3px; + display: flex; + justify-content: center; + align-items: center; + text-decoration: none; + color: black; +} + .journeys a.details-button { height: 30px; padding: 0;
- ${element.line.name} - → ${element.direction} - ${element.cancelled ? html`${t('cancelled-ride')}` : ''} + ${hasMarudorURL ? html` + ${leg.line.name} → ${leg.direction} + ` : html ` + ${leg.line.name} → ${leg.direction} + `} + ${leg.cancelled ? html`${t('cancelled-ride')}` : ''} ${Object.entries(remarks).map(remarksTemplate)} - ${travelynxTemplate(element)} + ${travelynxTemplate(leg)}
- ${element.line.additionalName ? html` + ${leg.line.additionalName ? html`
- Trip: ${element.line.additionalName} + Trip: ${leg.line.additionalName}
` : ''} - ${element.line.trainType ? html` + ${leg.line.trainType ? html`
- Train type: ${element.line.trainType} + Train type: ${leg.line.trainType}
` : ''}
- Duration: ${formatDuration((element.arrival.prognosedTime || element.arrival.plannedTime) - (element.departure.prognosedTime || element.departure.plannedTime))} + Duration: ${formatDuration((leg.arrival.prognosedTime || leg.arrival.plannedTime) - (leg.departure.prognosedTime || leg.departure.plannedTime))}
${timeTemplate(stop.arrival)} ${timeTemplate(stop.departure)}