ProxmoxAAS-Dashboard/scripts/settings.js

26 lines
804 B
JavaScript
Raw Normal View History

2023-08-09 00:33:51 +00:00
import { setTitleAndHeader } from "./utils.js";
2023-07-12 22:37:08 +00:00
window.addEventListener("DOMContentLoaded", init);
function init () {
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
}
document.querySelector("#settings").addEventListener("submit", handleSaveSettings, false);
}
function handleSaveSettings (event) {
event.preventDefault();
const form = new FormData(document.querySelector("#settings"));
2023-07-28 18:32:04 +00:00
console.log(form.get("sync-scheme"));
2023-07-12 22:37:08 +00:00
localStorage.setItem("sync-scheme", form.get("sync-scheme"));
localStorage.setItem("sync-rate", form.get("sync-rate"));
window.location.reload();
}