mirror of
https://github.com/thomiceli/opengist.git
synced 2024-12-23 04:52:40 +00:00
23 lines
774 B
TypeScript
23 lines
774 B
TypeScript
document.addEventListener('DOMContentLoaded', () => {
|
|
registerDomSetting(document.getElementById('disable-signup') as HTMLInputElement);
|
|
registerDomSetting(document.getElementById('require-login') as HTMLInputElement);
|
|
});
|
|
|
|
const setSetting = (key: string, value: string) => {
|
|
const data = new URLSearchParams();
|
|
data.append('key', key);
|
|
data.append('value', value);
|
|
data.append('_csrf', ((document.getElementsByName('_csrf')[0] as HTMLInputElement).value));
|
|
fetch('/admin-panel/set-setting', {
|
|
method: 'PUT',
|
|
credentials: 'same-origin',
|
|
body: data,
|
|
});
|
|
};
|
|
|
|
const registerDomSetting = (el: HTMLInputElement) => {
|
|
el.addEventListener('change', () => {
|
|
setSetting(el.id, el.checked ? '1' : '0');
|
|
});
|
|
};
|
|
|