1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { dataStorage } from './app.js';
import { showModal } from './overlays.js';
import { hideDiv, ElementById } from './helpers.js';
import { saveDataStorage, clearDataStorage, ConsoleLog, t, loadDS100 } from './app_functions.js';
import { html, render } from './lit-html.js';
import { searchView } from './searchView.js';
export const showSettings = () => {
showModal(t('settings'), settingsTemplate())
};
const settingsTemplate = () => html`
<div id="settingsView">
<b>${t('datasource')}:</b><br>
<label><input type="radio" name="provider" ?checked=${dataStorage.settings.provider === "DB"} value="DB"> DB</label><br>
<label><input type="radio" disabled="disabled" name="provider" ?checked=${dataStorage.settings.provider === "SH"} value="SH"> NAH.SH</label><br>
<label><input type="radio" disabled="disabled" name="provider" ?checked=${dataStorage.settings.provider === "BVG"} value="BVG"> BVG</label><br>
<br>
<b>${t('accessibility')}:</b><br>
<label><input type="radio" name="accessibility" ?checked=${dataStorage.settings.accessibility === "none"} value="none"> ${t('access_none')}</label><br>
<label><input type="radio" name="accessibility" ?checked=${dataStorage.settings.accessibility === "partial"} value="partial"> ${t('access_partial')}</label><br>
<label><input type="radio" name="accessibility" ?checked=${dataStorage.settings.accessibility === "complete"} value="complete"> ${t('access_full')}</label><br>
<br>
<b>${t('etc')}:</b><br>
<label><input type="checkbox" ?checked=${dataStorage.settings.showRIL100Names} id="ril100"> ${t('showds100')}</label><br>
<label><input type="checkbox" ?checked=${dataStorage.settings.writeDebugLog} id="debug-messages"> ${t('showdebug')}</label><br>
<label><input type="checkbox" ?checked=${dataStorage.settings.enableCanvas} id="enable-canvas"> ${t('graphical')} <b>BETA</b></label><br>
<label><input type="checkbox" ?checked=${dataStorage.settings.fancyCanvas} id="fancy-canvas"> ${t('fancy')}</label><br>
<label><input type="checkbox" ?checked=${dataStorage.settings.travelynx} id="travelynx"> ${t('travelynx-checkin')}</label><br>
<br>
<b>${t('language')}:</b><br>
<label><input type="radio" name="language" ?checked=${dataStorage.settings.language === "de"} value="de"> ${t('de')}</label><br>
<label><input type="radio" name="language" ?checked=${dataStorage.settings.language === "en"} value="en"> ${t('en')}</label><br>
<div class="buttons">
<button class="btn orange" id="rebuild-cache" @click=${rebuildCache}><span>${t('update')}</span></button>
<button class="btn red" id="clear" @click=${clearDataStorage}><span>${t('clearstorage')}</span></button>
<button class="btn" id="save" @click=${saveSettings}><span>${t('save')}</span></button>
</div>
</div>
`;
const rebuildCache = () => {
ConsoleLog('sw update');
registration.update();
location.reload();
};
const saveSettings = async () => {
const provider = document.querySelector('input[name="provider"]:checked').value;
const accessibility = document.querySelector('input[name="accessibility"]:checked').value;
const language = document.querySelector('input[name="language"]:checked').value;
const show_ril100 = ElementById('ril100').checked;
const write_debug = ElementById('debug-messages').checked;
const enable_canvas = ElementById('enable-canvas').checked;
const fancy_canvas = ElementById('fancy-canvas').checked;
const travelynx = ElementById('travelynx').checked;
if (provider !== dataStorage.settings.provider) {
dataStorage.journeysHistory = [];
}
dataStorage.settings.provider = provider;
dataStorage.settings.accessibility = accessibility;
dataStorage.settings.showRIL100Names = show_ril100;
dataStorage.settings.writeDebugLog = write_debug;
dataStorage.settings.enableCanvas = enable_canvas;
dataStorage.settings.fancyCanvas = fancy_canvas;
dataStorage.settings.language = language;
dataStorage.settings.travelynx = travelynx;
saveDataStorage();
if (show_ril100) await loadDS100();
searchView();
hideDiv('overlay');
};