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"); }); });