ctucx.git: oeffisearch

[nimlang] fast and simple tripplanner

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 
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('options')}:</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.travelynx} id="travelynx"> ${t('travelynx-checkin')}<label><br>
		<label><input type="checkbox" ?checked=${dataStorage.settings.advancedSelection} id="advancedSelection">ADVANCED® selection of trains<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>
	
		<button id="clear" @click=${clearDataStorage}><span>${t('clearstorage')}</span></button>
		<button id="save" @click=${saveSettings}><span>${t('save')}</span></button>

		<button id="quit" style="float:right;" @click=${newAll}><span>Quit Sibelius</span></button>
	</div>
`;

const rebuildCache = () => {
	ConsoleLog('sw update');
	registration.update();
	location.reload();
};

const newAll = () => {
	ElementById('clear').innerText = "New All";
};

const saveSettings  = async () => {
	const language          = document.querySelector('input[name="language"]:checked').value;
	const show_ril100       = ElementById('ril100').checked;
	const write_debug       = ElementById('debug-messages').checked;
	const travelynx         = ElementById('travelynx').checked;
	const advancedSelection = ElementById('advancedSelection').checked;

	dataStorage.settings.showRIL100Names   = show_ril100;
	dataStorage.settings.writeDebugLog     = write_debug;
	dataStorage.settings.language          = language;
	dataStorage.settings.travelynx         = travelynx;
	dataStorage.settings.advancedSelection = advancedSelection;

	saveDataStorage();
	if (show_ril100) await loadDS100();
	searchView();
	hideDiv('overlay');
};