67 lines
1.5 KiB
JavaScript
67 lines
1.5 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 editPost(id) {
|
|
fetch("director.php", {
|
|
method: "POST",
|
|
|
|
// TODO: Add Authorization header with JWT
|
|
headers: {
|
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
},
|
|
body: "ajaxId=editPostHTML&id=" + id,
|
|
})
|
|
.then((response) => {
|
|
return response.json();
|
|
})
|
|
.then((data) => {
|
|
openModal(data["html"]);
|
|
document.querySelector("#redirect").value = window.location.href;
|
|
});
|
|
}
|
|
|
|
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,
|
|
});
|
|
}
|