Initial commit :)
This commit is contained in:
36
public/whitelist/js/main.js
Normal file
36
public/whitelist/js/main.js
Normal file
@@ -0,0 +1,36 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const unlinkBtn = document.getElementById("unlinkBtn");
|
||||
if (unlinkBtn) {
|
||||
unlinkBtn.addEventListener("click", (e) => {
|
||||
e.preventDefault();
|
||||
if (confirm("Are you sure you want to unlink? This will remove your whitelist and delete your entry from our database.")) {
|
||||
window.location.href = "?action=unlink";
|
||||
}
|
||||
});
|
||||
}
|
||||
const whitelistForm = document.querySelector("form");
|
||||
if (whitelistForm) {
|
||||
whitelistForm.addEventListener("submit", () => {
|
||||
const btn = document.getElementById("whitelistBtn");
|
||||
const msg = document.getElementById("waitMsg");
|
||||
if (btn && msg) {
|
||||
btn.disabled = true;
|
||||
btn.textContent = "Please wait…";
|
||||
msg.style.display = "block";
|
||||
}
|
||||
});
|
||||
}
|
||||
const list = document.getElementById("whitelist");
|
||||
if (list) {
|
||||
list.addEventListener("dblclick", (ev) => {
|
||||
const li = ev.target.closest("li[data-name]");
|
||||
if (!li) return;
|
||||
const name = li.getAttribute("data-name");
|
||||
if (confirm(`Remove ${name} from whitelist?`)) {
|
||||
li.style.opacity = 0.5;
|
||||
li.textContent = `Removing ${name}…`;
|
||||
window.location.href = `?action=remove&name=${encodeURIComponent(name)}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user