2022-12-15 14:50:58 +00:00
|
|
|
document.addEventListener("DOMContentLoaded", () =>
|
|
|
|
{
|
|
|
|
fetch("isLoggedIn.php").then(res => res.json().then(json =>
|
|
|
|
{
|
|
|
|
if (json.message !== "ok")
|
|
|
|
{
|
|
|
|
window.location.href = "./";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
document.querySelector("#title h1").innerText = "Logged in as: " + json.username;
|
|
|
|
let adminLinks = document.querySelectorAll(".admin");
|
|
|
|
for (let adminLink of adminLinks)
|
|
|
|
{
|
|
|
|
if (json.admin === true)
|
|
|
|
{
|
|
|
|
adminLink.style.display = "block";
|
|
|
|
}
|
|
|
|
}
|
2022-12-09 04:51:56 +00:00
|
|
|
|
2022-12-15 14:50:58 +00:00
|
|
|
}
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
|
|
|
document.querySelector("#logout").addEventListener("click", e =>
|
|
|
|
{
|
|
|
|
e.preventDefault();
|
|
|
|
fetch("logout.php").then(res => res.json().then(json =>
|
|
|
|
{
|
|
|
|
if (json.message === "ok")
|
|
|
|
{
|
|
|
|
window.location.href = "./";
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
});
|