commit ae593ebf48d6b8e5a83594bcb64eb208a1067f7f
parent b26bc1016f782d89c0d8e97df709f97c8903d16e
Author: Katja (ctucx) <git@ctu.cx>
Date: Mon, 20 Jan 2025 15:52:22 +0100
parent b26bc1016f782d89c0d8e97df709f97c8903d16e
Author: Katja (ctucx) <git@ctu.cx>
Date: Mon, 20 Jan 2025 15:52:22 +0100
settings: rename `showRIL100Names` to `showDS100`
3 files changed, 20 insertions(+), 23 deletions(-)
diff --git a/src/app_functions.js b/src/app_functions.js @@ -12,7 +12,7 @@ let ds100 = {}; let ds100R = {}; subscribeSettings(async () => { - if (settings.showRIL100Names) await loadDS100(); + if (settings.showDS100) await loadDS100(); }); @@ -214,21 +214,25 @@ export const parseName = (point) => { }; export const ds100Names = (id) => { - if (!settings.showRIL100Names) return ''; - if (!ds100[Number(id)]) return ''; + if (!settings.showDS100) return ''; + if (!ds100[Number(id)]) return ''; + return '('+ds100[Number(id)]+')'; }; export const ds100Reverse = (name) => { - if (!settings.showRIL100Names) return null; - if (!ds100R[name]) return null; + if (!settings.showDS100) return null; + if (!ds100R[name]) return null; + return ds100R[name]; }; export const loadDS100 = async () => { const module = await import('./ds100.js'); - ds100 = module.ds100; + + ds100 = module.ds100; ds100R = {}; + for (let [id, names] of Object.entries(module.ds100)) { for (let name of names.split(", ")) { ds100R[name] = id;
diff --git a/src/settings.js b/src/settings.js @@ -24,7 +24,7 @@ const defaultSettings = { accessibility: 'none', journeysViewMode: 'canvas', showPrices: true, - showRIL100Names: true, + showDS100: true, }; const subscribers = [];
diff --git a/src/settingsView.js b/src/settingsView.js @@ -13,10 +13,6 @@ export const showSettings = async () => { const settingsTemplate = () => html` <div id="settingsView"> - <b>${t('options')}:</b><br> - <label><input type="checkbox" ?checked=${settings.showRIL100Names} id="ril100"> ${t('showds100')}</label><br> - <label><input type="checkbox" ?checked=${settings.showPrices} id="feature-prices"> ${t('show-prices')} (${t("experimental")})</label><br> - <br> <b>${t('language')}:</b><br> <label><input type="radio" name="language" ?checked=${settings.language === 'en'} value="en"> ${t('en')}</label><br> <label><input type="radio" name="language" ?checked=${settings.language === 'de'} value="de"> ${t('de')}</label><br> @@ -30,9 +26,12 @@ const settingsTemplate = () => html` <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> <br> - - <button class="button" id="clear" @click=${clearDataStorage}><span>${t('clearstorage')}</span></button> + <b>${t('options')}:</b><br> + <label><input type="checkbox" ?checked=${settings.showDS100} id="showDS100"> ${t('showds100')}</label><br> + <label><input type="checkbox" ?checked=${settings.showPrices} id="showPrices"> ${t('show-prices')} (${t("experimental")})</label><br> + <br> <button class="button" id="save" @click=${saveSettings}><span>${t('save')}</span></button> + <button class="button" style="float:right;" id="clear" @click=${clearDataStorage}><span>${t('clearstorage')}</span></button> </div> `; @@ -43,16 +42,10 @@ const rebuildCache = () => { const saveSettings = async () => { await modifySettings(settings => { - settings.showRIL100Names = ElementById('ril100').checked; - - const language = document.querySelector('input[name="language"]:checked').value; - settings.language = language; - - const profile = document.querySelector('input[name="profile"]:checked').value; - settings.profile = profile; - - const showPrices = ElementById('feature-prices').checked; - settings.showPrices = showPrices; + settings.showDS100 = ElementById('showDS100').checked; + settings.showPrices = ElementById('showPrices').checked; + settings.language = document.querySelector('input[name="language"]:checked').value; + settings.profile = document.querySelector('input[name="profile"]:checked').value; return settings; });