Files
2025-11-11 14:26:16 +07:00

36 lines
1.1 KiB
JavaScript

document.addEventListener("DOMContentLoaded", () => {
var theme = localStorage.getItem("bs-theme");
if (theme) {
document.documentElement.setAttribute("data-bs-theme", theme);
if (theme === "dark") {
themecheckbox.checked = true;
}
}
if (localStorage.getItem("token")) {
fetch(routes.access(), {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ token: localStorage.getItem("token") }),
})
.then((data) => data.json())
.then((jsondata) => {
if (jsondata.success) {
document.querySelector(".loginform").classList.remove("active");
get_all_users();
} else {
document.querySelector(".loginform").classList.add("active");
}
})
.catch((error) => {
notification(`Ошибка на сервере: ${error}`, "error");
});
usernameheader.innerHTML = JSON.parse(
localStorage.getItem("userdata"),
).username;
} else {
document.querySelector(".loginform").classList.add("active");
}
});