client/journey: show change duration
This commit is contained in:
parent
6846f77fce
commit
14aec20be3
|
@ -12,7 +12,7 @@ const remarksModalTemplate = (type, remarks) => html`
|
||||||
${remarks.map(element => html`
|
${remarks.map(element => html`
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<span class="remark ${type}"></span>
|
<span class="remark ${type}"></span>
|
||||||
<span>${element.text}</span>
|
<span>${element.text}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -37,38 +37,38 @@ const legTemplate = (element) => {
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
${element.isWalking ? html`
|
${element.isWalking ? html`
|
||||||
<p class="walk">${t('walkinfo', [parseName(element.arrival.point), element.distance])}</p>
|
<p class="walk">${t('walkinfo', [parseName(element.arrival.point), element.distance])}</p>
|
||||||
|
` : element.isTransfer ? html`
|
||||||
|
<p class="transfer">${t('transferinfo', [parseName(element.arrival.point)])}</p>
|
||||||
|
` : element.isChange ? html`
|
||||||
|
<p class="change">${t('changeinfo', [formatDuration(element.duration)])}</p>
|
||||||
` : html`
|
` : html`
|
||||||
${element.isTransfer ? html`
|
<table>
|
||||||
<p class="transfer">${t('transferinfo', [parseName(element.arrival.point)])}</p>
|
<thead>
|
||||||
` : html`
|
<tr>
|
||||||
<table>
|
<td colspan="4">
|
||||||
<thead>
|
${element.line.name} ${element.line.additionalName ? '('+element.line.additionalName+')' : ''} → ${element.direction} ${element.cancelled ? html`<b style="color:red;">${t('cancelled-ride')}</b>` : ''}
|
||||||
<tr>
|
${Object.entries(remarks).map(remarksTemplate)}
|
||||||
<td colspan="4">
|
</td>
|
||||||
${element.line.name} ${element.line.additionalName ? '('+element.line.additionalName+')' : ''} → ${element.direction} ${element.cancelled ? html`<b style="color:red;">${t('cancelled-ride')}</b>` : ''}
|
</tr>
|
||||||
${Object.entries(remarks).map(remarksTemplate)}
|
<tr>
|
||||||
</td>
|
<th>${t('arrival')}</th>
|
||||||
|
<th>${t('departure')}</th>
|
||||||
|
<th>${t('station')}</th>
|
||||||
|
<th>${t('platform')}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
${element.stopovers.map(stop => html`
|
||||||
|
<tr class="stop ${stop.cancelled ? 'cancelled' : ''}" @click=${() => {location.href = "https://marudor.de/"+stop.stop.id+"?searchType=hafas"}}>
|
||||||
|
<td>${timeTemplate(stop.arrival)}</td>
|
||||||
|
<td>${timeTemplate(stop.departure)}</td>
|
||||||
|
<td>${stop.stop.name} ${ds100Names(stop.stop.id)}</td>
|
||||||
|
<td>${stopPlatformTemplate(stop)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
`)}
|
||||||
<th>${t('arrival')}</th>
|
</tbody>
|
||||||
<th>${t('departure')}</th>
|
</table>
|
||||||
<th>${t('station')}</th>
|
|
||||||
<th>${t('platform')}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
${element.stopovers.map(stop => html`
|
|
||||||
<tr class="stop ${stop.cancelled ? 'cancelled' : ''}" @click=${() => {location.href = "https://marudor.de/"+stop.stop.id+"?searchType=hafas"}}>
|
|
||||||
<td>${timeTemplate(stop.arrival)}</td>
|
|
||||||
<td>${timeTemplate(stop.departure)}</td>
|
|
||||||
<td>${stop.stop.name} ${ds100Names(stop.stop.id)}</td>
|
|
||||||
<td>${stopPlatformTemplate(stop)}</td>
|
|
||||||
</tr>
|
|
||||||
`)}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
`}
|
|
||||||
`}
|
`}
|
||||||
`;
|
`;
|
||||||
};
|
};
|
||||||
|
@ -81,7 +81,36 @@ const journeyTemplate = (data, requestId, journeyId) => {
|
||||||
const arrivalTime = arrival.prognosedTime ? arrival.prognosedTime : arrival.plannedTime;
|
const arrivalTime = arrival.prognosedTime ? arrival.prognosedTime : arrival.plannedTime;
|
||||||
const duration = arrivalTime - departureTime;
|
const duration = arrivalTime - departureTime;
|
||||||
|
|
||||||
const changes = data.legs.filter(leg => !leg.isWalking).length;
|
const legs = [];
|
||||||
|
let changes = 0;
|
||||||
|
let lastArrival;
|
||||||
|
for (let leg of data.legs) {
|
||||||
|
if (!leg.isWalking && !leg.isTransfer) {
|
||||||
|
|
||||||
|
// add change
|
||||||
|
if (lastArrival) {
|
||||||
|
const departure = leg.departure;
|
||||||
|
const arrival = lastArrival;
|
||||||
|
const departureTime = departure.prognosedTime ? departure.prognosedTime : departure.plannedTime;
|
||||||
|
const arrivalTime = arrival.prognosedTime ? arrival.prognosedTime : arrival.plannedTime;
|
||||||
|
const duration = departureTime - arrivalTime;
|
||||||
|
|
||||||
|
legs.push({
|
||||||
|
isChange: true,
|
||||||
|
duration: duration,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
changes++;
|
||||||
|
|
||||||
|
lastArrival = leg.arrival;
|
||||||
|
} else if (legs.length) {
|
||||||
|
|
||||||
|
// if this is a walking leg and it is the first one, we don't want to
|
||||||
|
// insert a 0 minutes change entry for this
|
||||||
|
lastArrival = leg.arrival;
|
||||||
|
}
|
||||||
|
legs.push(leg);
|
||||||
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div id="journeyView">
|
<div id="journeyView">
|
||||||
|
@ -108,7 +137,7 @@ const journeyTemplate = (data, requestId, journeyId) => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="connection">
|
<div id="connection">
|
||||||
${data.legs.map(legTemplate)}
|
${legs.map(legTemplate)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -12,6 +12,7 @@ export const languages = {
|
||||||
'station': 'Station',
|
'station': 'Station',
|
||||||
'platform': 'Gleis',
|
'platform': 'Gleis',
|
||||||
'walkinfo': 'Laufe nach %s (ca. %s Meter)',
|
'walkinfo': 'Laufe nach %s (ca. %s Meter)',
|
||||||
|
'changeinfo': '%s Umstiegsdauer',
|
||||||
'transferinfo': 'Reise nach %s',
|
'transferinfo': 'Reise nach %s',
|
||||||
'swap': 'Von/Nach tauschen',
|
'swap': 'Von/Nach tauschen',
|
||||||
'settings': 'Einstellungen',
|
'settings': 'Einstellungen',
|
||||||
|
@ -59,6 +60,7 @@ export const languages = {
|
||||||
'station': 'Station',
|
'station': 'Station',
|
||||||
'platform': 'Platform',
|
'platform': 'Platform',
|
||||||
'walkinfo': 'Walk to %s (apprx. %s meters)',
|
'walkinfo': 'Walk to %s (apprx. %s meters)',
|
||||||
|
'changeinfo': '%s change duration',
|
||||||
'transferinfo': 'Travel to %s',
|
'transferinfo': 'Travel to %s',
|
||||||
'swap': 'Swap from/to',
|
'swap': 'Swap from/to',
|
||||||
'settings': 'Settings',
|
'settings': 'Settings',
|
||||||
|
|
Loading…
Reference in a new issue