import { html, nothing, render } from 'lit-html'; import { settings } from './settings.js'; import { remarksModalTemplate, platformTemplate, stopTemplate, timeTemplate } from './templates.js'; import { ElementById, showElement, setThemeColor, queryBackgroundColor } from './helpers.js'; import { processLeg } from './app_functions.js'; import { formatDateTime, formatDuration, formatPrice, formatLineAdditionalName, formatLineDisplayName } from './formatters.js'; import { showAlertModal, showLoader, hideOverlay, showModal } from './overlays.js'; import { go } from './router.js'; import { getHafasClient, client } from './hafasClient.js'; import { t } from './languages.js'; const tripTemplate = (data, profile, refreshToken) => { let changes = 0; let lastArrival; const remarks = data.remarks || []; const remarksStatus = remarks.some((obj) => obj.type === 'status'); const remarksWarning = remarks.some((obj) => obj.type === 'warning'); const remarksIcon = remarksWarning ? 'icon-warning' : (remarksStatus ? 'icon-status' : 'icon-hint'); let bahnExpertUrl = null; if (data.line && (data.line.product == 'nationalExpress' || data.line.product == 'national' || data.line.product == 'regionalExpress' || data.line.product == 'regional')) { const trainName = formatLineAdditionalName(data.line) || data.line?.name; if (trainName) { bahnExpertUrl = 'https://bahn.expert/details/' + encodeURIComponent(trainName) + '/' + Number(data.plannedDeparture); } } return html`
${bahnExpertUrl ? html`
${formatLineDisplayName(data.line)}${data.direction ? html` → ${data.direction}` : ''}
` : html `
${formatLineDisplayName(data.line)}${data.direction ? html` → ${data.direction}` : ''}
`}
${data.cancelled ? html`${t('cancelled-ride')}` : ''}
${!!remarks.length ? html` showModal(t('remarks'), remarksModalTemplate(remarks))}>` : nothing}
|
|||
${formatLineAdditionalName(data.line) ? html`
Trip: ${formatLineAdditionalName(data.line)}
` : nothing}
${data.line.trainType ? html`
Train type: ${data.line.trainType}
` : nothing}
${t('duration')}: ${formatDuration(data.arrival - (data.departure ? data.departure : data.plannedDeparture))} ${data.departure ? '' : ('(' + t('planned') + ')')}
${data.loadFactor ? html`
` : nothing}
|
|||
${t('arrival')} | ${t('departure')} | ${t('station')} | ${t('platform')} |
---|---|---|---|
${timeTemplate(stop, 'arrival')} | ${timeTemplate(stop, 'departure')} | ${stopTemplate(profile, stop.stop)} | ${platformTemplate(stop)} |