rough implementations of Moment and Essay creation and viewing completed.
This commit is contained in:
+1
-3
@@ -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";
|
||||
});
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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"]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -24,8 +24,6 @@ if (logout) {
|
||||
|
||||
if (login) {
|
||||
login.addEventListener("click", () => {
|
||||
console.log("click");
|
||||
|
||||
fetch("director.php", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user