ProxmoxAAS-Dashboard/scripts/settings.js

36 lines
1.2 KiB
JavaScript
Raw Normal View History

2024-06-14 06:17:15 +00:00
import { setTitleAndHeader, setAppearance } from "./utils.js";
2023-08-09 00:33:51 +00:00
2023-07-12 22:37:08 +00:00
window.addEventListener("DOMContentLoaded", init);
function init () {
2024-06-14 06:17:15 +00:00
setAppearance();
2023-08-09 00:33:51 +00:00
setTitleAndHeader();
2023-07-28 18:32:04 +00:00
const scheme = localStorage.getItem("sync-scheme");
2023-07-12 22:37:08 +00:00
if (scheme) {
document.querySelector(`#sync-${scheme}`).checked = true;
}
2023-07-28 18:32:04 +00:00
const rate = localStorage.getItem("sync-rate");
2023-07-12 22:37:08 +00:00
if (rate) {
2023-07-28 18:32:04 +00:00
document.querySelector("#sync-rate").value = rate;
2023-07-12 22:37:08 +00:00
}
2024-06-05 22:11:53 +00:00
const search = localStorage.getItem("search-criteria");
if (search) {
document.querySelector(`#search-${search}`).checked = true;
}
2024-06-14 06:17:15 +00:00
const theme = localStorage.getItem("appearance-theme");
if (theme) {
document.querySelector("#appearance-theme").value = theme;
}
2023-07-12 22:37:08 +00:00
document.querySelector("#settings").addEventListener("submit", handleSaveSettings, false);
}
function handleSaveSettings (event) {
event.preventDefault();
const form = new FormData(document.querySelector("#settings"));
localStorage.setItem("sync-scheme", form.get("sync-scheme"));
localStorage.setItem("sync-rate", form.get("sync-rate"));
2024-06-05 22:11:53 +00:00
localStorage.setItem("search-criteria", form.get("search-criteria"));
2024-06-14 06:17:15 +00:00
localStorage.setItem("appearance-theme", form.get("appearance-theme"));
2023-07-12 22:37:08 +00:00
window.location.reload();
}