better front end js

This commit is contained in:
Akif9748 2022-08-29 16:26:34 +03:00
parent 52eda8ddad
commit 0ee3d3be8b
2 changed files with 7 additions and 20 deletions

View File

@ -17,22 +17,10 @@ document.getElementById("send")?.addEventListener("submit", async e => {
/**
* OTHER FUNCTIONS
*/
window.delete_thread = async function (id) {
const response = await request("/api/threads/" + id + "/delete");
if (response.deleted) {
alert("Thread deleted");
location.reload();
}
}
window.undelete_thread = async function (id) {
const response = await request("/api/threads/" + id + "/undelete");
if (!response.deleted) {
alert("Thread undeleted");
location.reload();
}
window.thread = async function (id, un= "") {
await request(`/api/threads/${id}/${un}delete`);
alert(`Thread ${un}deleted`);
location.reload();
}
window.undelete_message = async function (id) {
const response = await request(`/api/messages/${id}/undelete`);
@ -53,8 +41,7 @@ window.delete_message = async function (id) {
<i class='bx bx-trash bx-sm' id="deleted-${id}" style="color: RED;"></i>
`+ document.getElementById("dots-" + id).innerHTML;
document.getElementById("dot-" + id).innerHTML = `
<a onclick="undelete_message('${id}');">UNDELETE</a>`;// ADMIN PERM FIX
document.getElementById("dot-" + id).innerHTML = `<a onclick="undelete_message('${id}');">UNDELETE</a>`;
}
}
window.react = async function (id, type) {

View File

@ -25,11 +25,11 @@
<% if (user && !thread.deleted){ %>
<a onclick="delete_thread('<%= thread.id %>' )" class="btn-outline-primary" >DELETE</a>
<a onclick="thread('<%= thread.id %>')" class="btn-outline-primary" >DELETE</a>
<a onclick="edit_thread('<%= thread.id %>')" class="btn-outline-primary" >EDIT</a>
<% } else if (thread.deleted) { %>
<h3 style="display:inline;">This thread has been deleted</h3>
<a onclick="undelete_thread('<%= thread.id %>')" class="btn-primary" >UNDELETE</a>
<a onclick="thread('<%= thread.id %>', 'un')" class="btn-primary" >UNDELETE</a>
<% }; %>
</div>