ctucx.git: trainsearch

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

commit 930eb928236ad04f5b781c1ac3afe320c688fe2e
parent b465392356bf0747e56130d8f847bda28a976705
Author: Katja (ctucx) <git@ctu.cx>
Date: Tue, 21 Jan 2025 22:46:09 +0100

tripView: add back button if possible
1 file changed, 6 insertions(+), 2 deletions(-)
M
src/tripView.js
|
8
++++++--
diff --git a/src/tripView.js b/src/tripView.js
@@ -30,9 +30,9 @@ const tripTemplate = (data, profile) => {
 	return html`
 		<div class="journey">
 			<header>
-				<a class="icon-back hidden"></a>
+				<a id="back" class="icon-back hidden" title="${t('back')}" @click=${() => history.back()}>${t('back')}</a>
 				<div class="content">
-					<h3>Trip of ${lineDisplayName(data.line)}</h3>
+					<h3>Trip of ${lineDisplayName(data.line)} to ${data.direction}</h3>
 				</div>
 				<a class="icon-reload hidden">${t("reload")}</a>
 			</header>

@@ -114,4 +114,8 @@ export const tripView = async (match, isUpdate) => {
 	hideOverlay();
 
 	render(tripTemplate(data.trip, profile), ElementById('content'));
+
+	if (history.length > 0) {
+		ElementById('back').classList.remove('hidden');
+	}
 };