import { html, nothing, render } from 'lit-html'; import { cachedCoachSequence } from './coach-sequence/index.js'; import { settings } from './settings.js'; import { remarksModalTemplate, platformTemplate, stopTemplate, timeTemplate, footerTemplate } from './templates.js'; import { ElementById, setThemeColor, queryBackgroundColor } from './helpers.js'; import { getJourney, refreshJourney } from './app_functions.js'; import { formatName, formatDateTime, formatDuration, formatPrice, formatTrainTypes, formatLineAdditionalName, formatLineDisplayName } from './formatters.js'; import { showAlertModal, showLoader, hideOverlay, showModal } from './overlays.js'; import { go } from './router.js'; import { t } from './languages.js'; import { db } from './dataStorage.js'; import { showSelectModal } from './overlays.js'; const legTemplate = (leg, profile) => { const remarks = leg.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'); return html` ${leg.walking ? html`
${t(leg.distance === null ? 'walkinfo' : 'walkinfo_meters', formatName(leg.destination), leg.distance)}
` : leg.transfer ? html`${t('transferinfo', formatName(leg.destination))}
` : leg.change ? html`${t('changeinfo', formatDuration(leg.duration))}
` : html`
${formatLineDisplayName(leg.line)}${leg.direction ? html` → ${leg.direction}` : nothing}
${leg.cancelled ? html`${t('cancelled-ride')}` : nothing}
${!!remarks.length ? html`
showModal(t('remarks'), remarksModalTemplate(remarks))}>
` : nothing}
|
|||
${formatLineAdditionalName(leg.line) ? html`
Trip: ${formatLineAdditionalName(leg.line)}
` : nothing}
${leg.line.trainType ? html`
Train type: ${leg.line.trainType}
` : nothing}
${(leg.arrival && leg.departure) ? html`
${t('duration')}: ${formatDuration(leg.arrival - leg.departure)}
` : nothing}
${leg.loadFactor ? html`
${t("load-"+leg.loadFactor)}
` : nothing}
|
|||
${t('arrival')} | ${t('departure')} | ${t('station')} | ${t('platform')} |
---|---|---|---|
${timeTemplate(stop, 'arrival')} | ${timeTemplate(stop, 'departure')} | ${stopTemplate(profile, stop.stop)} | ${platformTemplate(stop)} |
${t('duration')}: ${formatDuration(duration)} | ${t('changes')}: ${changes-1} | ${t('date')}: ${formatDateTime(data.legs[0].plannedDeparture, 'date')}${settings.showPrices && settings.profile === 'db' && data.price ? html` | ${t('price')}: