2019-10-05 02:09:52 +02:00
|
|
|
/**
|
|
|
|
* Settings.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { $, $$ } from './utils/dom';
|
|
|
|
import store from './utils/store';
|
|
|
|
|
|
|
|
export function setupSettings() {
|
2024-06-06 18:48:16 +02:00
|
|
|
if (!$<HTMLElement>('#js-setting-table')) return;
|
2019-10-05 02:09:52 +02:00
|
|
|
|
2024-06-06 18:48:16 +02:00
|
|
|
const localCheckboxes = $$<HTMLInputElement>('[data-tab="local"] input[type="checkbox"]');
|
|
|
|
const themeSelect = $<HTMLSelectElement>('#user_theme');
|
|
|
|
const styleSheet = $<HTMLLinkElement>('head link[rel="stylesheet"]');
|
2019-10-05 02:09:52 +02:00
|
|
|
|
|
|
|
// Local settings
|
|
|
|
localCheckboxes.forEach(checkbox => {
|
|
|
|
checkbox.addEventListener('change', () => {
|
2020-01-01 17:05:44 +01:00
|
|
|
store.set(checkbox.id.replace('user_', ''), checkbox.checked);
|
2019-10-05 02:09:52 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// Theme preview
|
|
|
|
themeSelect && themeSelect.addEventListener('change', () => {
|
2024-06-06 18:48:16 +02:00
|
|
|
if (styleSheet) {
|
|
|
|
styleSheet.href = themeSelect.options[themeSelect.selectedIndex].dataset.themePath || '#';
|
|
|
|
}
|
2019-10-05 02:09:52 +02:00
|
|
|
});
|
|
|
|
}
|