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,23 +17,11 @@ 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");
window.thread = async function (id, un= "") {
await request(`/api/threads/${id}/${un}delete`);
alert(`Thread ${un}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.undelete_message = async function (id) {
const response = await request(`/api/messages/${id}/undelete`);
if (response.deleted) return;
@ -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>