ctucx.git: trainsearch

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

commit b9d5a883b2c262001daa1a8565b4c34bdf9880ef
parent 55f1e864a25a76d5d9b5a424ad063bf154981c50
Author: Katja (ctucx) <git@ctu.cx>
Date: Sun, 19 Jan 2025 15:40:51 +0100

some cleanups
6 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/package.json b/package.json
@@ -5,7 +5,7 @@
   "main": "service-worker.js",
   "scripts": {
     "build": "rm -rf dist && webpack",
-    "start": "rm -rf dist && webpack-dev-server --open -d"
+    "start": "rm -rf dist && webpack-dev-server --open"
   },
   "author": "",
   "license": "AGPL-3.0",
diff --git a/src/app_functions.js b/src/app_functions.js
@@ -82,6 +82,7 @@ export const processLeg = leg => {
 		if (stopover.when) stopover.when = new Date(stopover.when);
 	}
 };
+
 const processJourney = journey => {
 	for (const leg of journey.legs) {
 		processLeg(leg);

@@ -137,10 +138,12 @@ export const getMoreJourneys = async (slug, mode) => {
 
 	await addJourneys(res);
 };
+
 export const refreshJourneys = async (slug) => {
 	const saved = await db.getJourneysOverview(slug);
 	await Promise.all(saved.journeys.map(x => refreshJourney(x, saved.profile || "db")));
 };
+
 export const refreshJourney = async (refreshToken, profile) => {
 	const client = await getHafasClient(profile || settings.profile || "db");
 	const requestSettings = mkSettings();

@@ -217,6 +220,7 @@ const ds100Names = (id) => {
 	if (!ds100[Number(id)]) return '';
 	return '('+ds100[Number(id)]+')';
 };
+
 export const ds100Reverse = (name) => {
 	if (!settings.showRIL100Names) return null;
 	if (!ds100R[name]) return null;
diff --git a/src/searchView.js b/src/searchView.js
@@ -175,7 +175,6 @@ export const search = async (requestId) => {
 		return settings;
 	});
 
-	const provider = settings.provider;
 	const isDep = ElementById('departure').checked;
 	let date = ElementById('date').value;
 	let time = ElementById('time').value;

@@ -350,7 +349,6 @@ export const setFromHistory = async id => {
 };
 
 export const readProductSelection = settings => {
-	const splitExp = settings.advancedSelection;
 	const productsMap = {};
 	for (const prod of client.profile.products) {
 		productsMap[prod.id] = ElementById(prod.id).checked;
diff --git a/src/settings.js b/src/settings.js
@@ -7,7 +7,8 @@ const getDefaultLanguage = () => {
 };
 
 const defaultSettings = {
-	provider: 'DB',
+	language: getDefaultLanguage(),
+	profile: "db",
 	products: {
 		'nationalExpress': true,
 		'national': true,

@@ -21,13 +22,10 @@ const defaultSettings = {
 		'taxi': true
 	},
 	accessibility: 'none',
-	advancedSelection: false,
-	showRIL100Names: false,
-	writeDebugLog: false,
-	language: getDefaultLanguage(),
 	journeysViewMode: 'canvas',
-	showPrices: false,
-	profile: "db",
+	showPrices: true,
+	showRIL100Names: true,
+	writeDebugLog: false,
 };
 
 const subscribers = [];
diff --git a/src/settingsView.js b/src/settingsView.js
@@ -16,7 +16,6 @@ const settingsTemplate = () => html`
 		<b>${t('options')}:</b><br>
 		<label><input type="checkbox" ?checked=${settings.showRIL100Names} id="ril100"> ${t('showds100')}</label><br>
 		<label><input type="checkbox" ?checked=${settings.writeDebugLog} id="debug-messages"> ${t('showdebug')}</label><br>
-		<label><input type="checkbox" ?checked=${settings.advancedSelection} id="advancedSelection">ADVANCED® selection of trains</label><br>
 		<br>
 		<b>${t('language')}:</b><br>
 		<label><input type="radio" name="language" ?checked=${settings.language === 'en'} value="en"> ${t('en')}</label><br>

@@ -28,8 +27,6 @@ const settingsTemplate = () => html`
 		<label><input type="radio" name="profile" ?checked=${settings.profile === 'nahsh'} value="nahsh"> NAH.SH (${t("experimental")})</label><br>
 		<label><input type="radio" name="profile" ?checked=${settings.profile === 'bvg'} value="bvg"> BVG (${t("experimental")})</label><br>
 		<label><input type="radio" name="profile" ?checked=${settings.profile === 'oebb'} value="oebb"> ÖBB (${t("experimental")})</label><br>
-		<!--<label><input type="radio" name="profile" ?checked=${settings.profile === 'sncb'} value="sncb"> SNCB (${t("experimental")})</label><br>-->
-		<!--<label><input type="radio" name="profile" ?checked=${settings.profile === 'sncf'} value="sncf"> SNCF (${t("experimental")})</label><br>-->
 		<br>
 		<b>${t('experimental-features')}:</b><br>
 		<label><input type="checkbox" ?checked=${settings.showPrices} id="feature-prices"> ${t('show-prices')}</label><br>

@@ -54,9 +51,8 @@ const newAll = () => {
 
 const saveSettings = async () => {
 	await modifySettings(settings => {
-		settings.showRIL100Names = ElementById('ril100').checked;
-		settings.writeDebugLog = ElementById('debug-messages').checked;
-		settings.advancedSelection = ElementById('advancedSelection').checked;
+		settings.showRIL100Names   = ElementById('ril100').checked;
+		settings.writeDebugLog     = ElementById('debug-messages').checked;
 
 		const language = document.querySelector('input[name="language"]:checked').value;
 		settings.language = language;

@@ -69,6 +65,7 @@ const saveSettings = async () => {
 
 		return settings;
 	});
+
 	await initHafasClient(settings.profile);
 	searchView();
 	hideDiv('overlay');
diff --git a/src/templates.js b/src/templates.js
@@ -20,6 +20,7 @@ export const remarksModalTemplate = (type, remarks) => html`
 export const showRemarksModal = (type, remarks) => {
 	showModal(t('remarks'), remarksModalTemplate(type, remarks));
 };
+
 export const remarksTemplate = ([type, remarks]) => !!remarks.length ? html`
 	<a class="link icon-${type}" @click=${() => showRemarksModal(type, remarks)}></a>
 ` : '';