nextcloud-pride-flags/js/pride-settings.js
2024-07-29 20:45:34 +02:00

28 lines
809 B
JavaScript

const folder_selector = document.querySelectorAll('.pride_flags_user_settings .user-settings.folder select');
const button_selector = document.querySelectorAll('.pride_flags_user_settings .user-settings.button select');
fetch('/index.php/apps/pride_flags/settings')
.then(res => JSON.parse(res))
.then(({folderPrideVariant, buttonPrideVariant}) => {
folder_selector.value = folderPrideVariant;
button_selector.value = buttonPrideVariant;
});
function save() {
const payload = {
folderVariant: folder_selector.value,
buttonVariant: button_selector.value,
}
fetch('index.php/apps/pride_flags/settings', {
method: 'POST',
body: JSON.stringify(payload),
headers: {
"Content-Type": "application/json",
}
}).then(response => {
if (response.ok) {
window.location.reload();
}
})
}