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
|
|
|
}
|
2024-06-05 22:11:53 +00:00
|
|
|
const search = localStorage.getItem("search-criteria");
|
|
|
|
if (search) {
|
|
|
|
document.querySelector(`#search-${search}`).checked = true;
|
|
|
|
}
|
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"));
|
2023-07-12 22:37:08 +00:00
|
|
|
window.location.reload();
|
|
|
|
}
|