Files
web/js/dropdown.js
T

48 lines
1.1 KiB
JavaScript

let dropdowns = document.querySelectorAll(".dropdown");
dropdowns.forEach((el) => {
el.addEventListener("click", (e) => {
e.stopPropagation();
let dropContent = el.querySelector(".dropdownContent");
dropContent.style.display = "block";
dropContent.addEventListener("click", (e) => {
e.stopPropagation();
});
});
});
window.addEventListener("click", () => {
document.querySelectorAll(".dropdownContent").forEach((dc) => {
dc.style.display = "none";
});
});
function deleteSpace(id) {
document.querySelector("#space-" + id).remove();
fetch("director.php", {
method: "POST",
// TODO: Add Authorization header with JWT
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: "ajaxId=deleteSpace&id=" + id,
});
}
function deletePost(id) {
document.querySelector("#post-" + id).remove();
fetch("director.php", {
method: "POST",
// TODO: Add Authorization header with JWT
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: "ajaxId=deletePost&id=" + id,
});
}