rough implementations of Moment and Essay creation and viewing completed.

This commit is contained in:
2025-06-04 14:53:02 -06:00
parent 088e0cc5a3
commit becfbc3628
14 changed files with 465 additions and 134 deletions
+1 -3
View File
@@ -55,6 +55,7 @@ actionPost.addEventListener("click", () => {
return response.json();
})
.then((data) => {
console.log(data["html"]);
openModal(data["html"]);
document.querySelector("#redirect").value = window.location.href;
@@ -68,8 +69,6 @@ actionPost.addEventListener("click", () => {
let newPostLabel = document.querySelector("#newPostLabel");
let postType = document.querySelector("#postType");
let share = document.querySelector("#share");
newNavThought.addEventListener("click", () => {
newMoment.style.display = "none";
newEssay.style.display = "none";
@@ -86,7 +85,6 @@ actionPost.addEventListener("click", () => {
newMoment.style.display = "flex";
newPostLabel.innerText = "New Moment";
newMoment.querySelector('input[type="text"]').focus();
postType.value = "Moment";
});
+19
View File
@@ -18,6 +18,25 @@ window.addEventListener("click", () => {
});
});
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();
+24
View File
@@ -0,0 +1,24 @@
let essays = document.querySelectorAll(".divLink");
essays.forEach((e) => {
let link = e.querySelector("a").href;
let id = link.split("=")[2];
e.addEventListener("click", () => {
fetch("director.php", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: "ajaxId=viewEssay&id=" + id,
})
.then((response) => {
return response.json();
})
.then((data) => {
if (!data["html"]) return;
openModal(data["html"]);
});
});
});
-2
View File
@@ -24,8 +24,6 @@ if (logout) {
if (login) {
login.addEventListener("click", () => {
console.log("click");
fetch("director.php", {
method: "POST",
headers: {