user/admin blah

This commit is contained in:
Flummi
2025-04-28 10:42:00 +02:00
parent 728f044066
commit b9b3aebf2e
3 changed files with 239 additions and 61 deletions

View File

@ -1,41 +1,3 @@
let flashActive = false;
const flashTypes = [ "error", "success", "warn" ];
const flash = ({ type, msg }) => {
let flashContainer;
if(tmp = document.querySelector("div#flash"))
flashContainer = tmp;
else {
flashContainer = document.createElement("div");
flashContainer.id = "flash";
document.body.insertAdjacentElement("afterbegin", flashContainer);
}
flashContainer.innerHTML = msg;
if(flashTypes.includes(type)) {
flashContainer.className = "";
flashContainer.classList.add(type);
}
if(flashActive)
return false;
flashActive = true;
flashContainer.animate(
[ { bottom: "-28px" }, { bottom: 0 } ], {
duration: 500,
fill: "both"
}
).onfinish = () => setTimeout(() => {
flashContainer.animate(
[ { bottom: 0 }, { bottom: "-28px" } ], {
duration: 500,
fill: "both"
}
).onfinish = () => flashActive = false;
}, 4 * 1e3);
return true;
};
(async () => {
if(_addtag = document.querySelector("a#a_addtag")) {
const postid = +document.querySelector("a.id-link").innerText;
@ -140,10 +102,8 @@ const flash = ({ type, msg }) => {
tagname: tmptag
});
if(!res.success) {
return flash({
type: "error",
msg: res.msg
});
alert(res.msg);
return false;
}
tags = res.tags.map(t => t.tag);
renderTags(res.tags);
@ -202,12 +162,6 @@ const flash = ({ type, msg }) => {
})).json();
renderTags(res.tags);
tags = res.tags.map(t => t.tag);
flash({
type: "success",
msg: tags.join()
});
};
const deleteButtonEvent = async e => {
@ -218,17 +172,8 @@ const flash = ({ type, msg }) => {
const res = await post("/api/v2/admin/deletepost", {
postid: postid
});
if(res.success) {
flash({
type: "success",
msg: "post was successfully deleted"
});
}
else {
flash({
type: "error",
msg: res.msg
});
if(!res.success) {
alert(res.msg);
}
};