(() => { let selection = null; if (document.location.hash !== null && (selection = document.getElementById(document.location.hash.replace("#", ""))) !== null) { selection.classList.add("selected"); } function removeEntry(dn) { let csrfToken = document.getElementById("csrf").value; if (!csrfToken) return; let req = new XMLHttpRequest(); req.onreadystatechange = () => { if (req.readyState === 4) { if (req.status === 203) document.location.reload(); else alert("Error: " +req.statusText); } } req.open("DELETE", "/entity?dn=" + encodeURIComponent(dn) + "&csrf=" + encodeURIComponent(csrfToken)); req.send(); } document.querySelectorAll('.action-remove').forEach(i => { i.addEventListener('click', (e) => { let dn = e.target.dataset["dn"] || e.currentTarget.dataset["dn"]; if (!dn) return; if (!window.confirm("Really remove entry " + dn + " ?")) return; removeEntry(dn); }); }); })();