blob: 06ab9128f60e3444125794c4ba8a6d91a23ba778 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
// SPDX-FileCopyrightText: 2026 Dennis Fink <me+coding@dennisfink.me>
//
// SPDX-License-Identifier: BSD-3-Clause
document.addEventListener("DOMContentLoaded", () => {
const checkboxes = Array.from(document.querySelectorAll(".received-select"));
const selectAll = document.getElementById("received-select-all");
const bulkButtons = document.querySelectorAll("[data-received-bulk-action]");
const count = document.getElementById("received-selected-count");
const modal = document.getElementById("confirmation-modal");
const selected = () => checkboxes.filter((checkbox) => checkbox.checked);
const updateSelection = () => {
const selectedCount = selected().length;
if (count !== null) {
count.textContent = `${selectedCount} selected`;
}
bulkButtons.forEach((button) => {
button.disabled = selectedCount === 0;
});
if (selectAll !== null) {
selectAll.checked = selectedCount === checkboxes.length;
selectAll.indeterminate =
selectedCount > 0 && selectedCount < checkboxes.length;
}
};
selectAll?.addEventListener("change", () => {
checkboxes.forEach((checkbox) => {
checkbox.checked = selectAll.checked;
});
updateSelection();
});
checkboxes.forEach((checkbox) => {
checkbox.addEventListener("change", updateSelection);
});
modal?.addEventListener("show.bs.modal", (event) => {
const form = modal.querySelector("#confirmation-modal-form");
// Never carry a previous bulk selection into an unrelated confirmation.
form.querySelectorAll('input[name="webmention_uuids"]').forEach((input) => {
input.remove();
});
if (!event.relatedTarget?.dataset.receivedBulkAction) {
return;
}
const selection = selected();
const message = modal.querySelector("#confirmation-modal-message");
const action = event.relatedTarget.dataset.receivedBulkAction;
if (action === "delete") {
message.textContent = `This permanently deletes ${selection.length} selected webmentions and cannot be undone.`;
} else if (action === "block-sources") {
message.textContent = `Source domains from ${selection.length} selected webmentions (and their subdomains) will be blocked. Existing webmentions will be kept.`;
} else {
message.textContent = `${selection.length} selected webmentions will be fetched and verified again.`;
}
selection.forEach((checkbox) => {
const input = document.createElement("input");
input.type = "hidden";
input.name = "webmention_uuids";
input.value = checkbox.value;
form.appendChild(input);
});
});
updateSelection();
});
|