Files
tgirl.city/public/whitelist/js/main.js
2025-11-20 01:00:38 -08:00

36 lines
1.3 KiB
JavaScript

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