You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
913 B
37 lines
913 B
let ll = document.getElementById("linklist");
|
|
let infoBox = document.getElementById("general-info");
|
|
|
|
ll.addEventListener("click", e => {
|
|
|
|
let rbtn = e.target;
|
|
|
|
if (!rbtn.classList.contains("btn-delete")) {
|
|
return;
|
|
}
|
|
|
|
e.preventDefault();
|
|
|
|
let row = e.target.parentNode.parentNode;
|
|
let link_id = row.children[0].dataset.id;
|
|
|
|
toggleDisabled(rbtn, "on");
|
|
|
|
fetch("/linklist", {
|
|
method: "DELETE",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify({id: link_id})
|
|
}).then(res => {
|
|
if (res.status == 200) {
|
|
row.remove();
|
|
} else {
|
|
setInfo(infoBox, "Failure", "red", "grey1");
|
|
toggleHidden(infoBox, "off");
|
|
setTimeout(() => {
|
|
toggleHidden(infoBox, "on");
|
|
}, 2000);
|
|
}
|
|
toggleDisabled(rbtn, "off");
|
|
});
|
|
}); |