mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 14:57:59 +01:00
29 lines
885 B
TypeScript
29 lines
885 B
TypeScript
/**
|
|
* Settings.
|
|
*/
|
|
|
|
import { assertNotNull, assertNotUndefined } from './utils/assert';
|
|
import { $, $$ } from './utils/dom';
|
|
import store from './utils/store';
|
|
|
|
export function setupSettings() {
|
|
|
|
if (!$('#js-setting-table')) return;
|
|
|
|
const localCheckboxes = $$<HTMLInputElement>('[data-tab="local"] input[type="checkbox"]');
|
|
const themeSelect = assertNotNull($<HTMLSelectElement>('#user_theme'));
|
|
const styleSheet = assertNotNull($<HTMLLinkElement>('head link[rel="stylesheet"]'));
|
|
|
|
// Local settings
|
|
localCheckboxes.forEach(checkbox => {
|
|
checkbox.addEventListener('change', () => {
|
|
store.set(checkbox.id.replace('user_', ''), checkbox.checked);
|
|
});
|
|
});
|
|
|
|
// Theme preview
|
|
themeSelect && themeSelect.addEventListener('change', () => {
|
|
styleSheet.href = assertNotUndefined(themeSelect.options[themeSelect.selectedIndex].dataset.themePath);
|
|
});
|
|
|
|
}
|