<div style="margin-bottom: 20px; background: #f4f5f7; padding: 15px; border-radius: 3px; border: 1px solid #dfe1e6;">
                    <button type="button" id="delete-selected-attachments" class="aui-button aui-button-primary">Delete Selected Attachments</button>
                    <label style="margin-left: 15px; cursor: pointer; font-weight: bold;">
                        <input type="checkbox" id="select-all-checkbox" style="vertical-align: middle;"> Select All
                    </label>
                    <div id="status-message" style="margin-top: 10px; display: none; font-weight: bold; color: #0052cc;"></div>
                </div>
                <script type="text/javascript">
                (function() {
                    const mainDoc = window.parent.document;
                    const selectAll = document.getElementById("select-all-checkbox");
                    const deleteBtn = document.getElementById("delete-selected-attachments");
                    const statusMsg = document.getElementById("status-message");

                    if (selectAll) {
                        selectAll.addEventListener("change", function() {
                            mainDoc.querySelectorAll(".attachment-checkbox").forEach(cb => cb.checked = selectAll.checked);
                        });
                    }

                    deleteBtn.addEventListener("click", async function() {
                        const selected = mainDoc.querySelectorAll(".attachment-checkbox:checked");
                        const ids = Array.from(selected).map(cb => cb.getAttribute("data-attachment-id"));
                        if (ids.length === 0) { alert("Please select at least one."); return; }
                        if (!confirm("Delete " + ids.length + " files?")) return;

                        deleteBtn.disabled = true;
                        statusMsg.style.display = "block";
                        statusMsg.textContent = "Processing...";

                        try {
                            const res = await fetch("https://support.emsa.europa.eu/kb/rest/scriptrunner/latest/custom/bulkDeleteAttachmentsv2", {
                                method: "POST", headers: {"Content-Type":"application/json","X-Atlassian-Token":"no-check"}, body: JSON.stringify({ attachmentIds: ids })
                            });
                            if (res.ok) {
                                await fetch("https://support.emsa.europa.eu/kb/rest/scriptrunner/latest/custom/listRefresh", {
                                    method: "POST", headers: {"Content-Type":"application/json","X-Atlassian-Token":"no-check"}, body: JSON.stringify({ spaceKey: window.parent.AJS.params.spaceKey })
                                });
                                window.parent.location.reload();
                            } else { alert("Error: " + res.status); deleteBtn.disabled = false; }
                        } catch (err) { alert("Failed: " + err.message); deleteBtn.disabled = false; }
                    });
                })();
                </script>
            
SelectAttachmentPageSize (MB)
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86284525" style="width:20px; height:20px; cursor:pointer;">
3.2.2.3 Check Distribution - Search Results.png3.2.2.3 Check Distribution0.03
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86284526" style="width:20px; height:20px; cursor:pointer;">
3.2.2.3 Distribution Status.png3.2.2.3 Check Distribution0.05
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86284524" style="width:20px; height:20px; cursor:pointer;">
3.2.2.3 Check Distribution - Search Form.png3.2.2.3 Check Distribution0.02
<input type="checkbox" class="attachment-checkbox" data-attachment-id="292488592" style="width:20px; height:20px; cursor:pointer;">
image-2026-7-20_16-26-46.png3.2.2.2 Update-Delete Feedback0.04
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86284523" style="width:20px; height:20px; cursor:pointer;">
3.2.2.2 Update-Delete-Feedback - Search Results.png3.2.2.2 Update-Delete Feedback0.02
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86284521" style="width:20px; height:20px; cursor:pointer;">
3.2.2.2 Update-Delete-Feedback - Provide Feedback Form.png3.2.2.2 Update-Delete Feedback0.03
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86284520" style="width:20px; height:20px; cursor:pointer;">
3.2.2.2 Update-Delete-Feedback - Edit Form.png3.2.2.2 Update-Delete Feedback0.05
<input type="checkbox" class="attachment-checkbox" data-attachment-id="292488610" style="width:20px; height:20px; cursor:pointer;">
image-2026-7-20_16-37-50.png3.3.6.1 Incidents for non-identified ships0.04
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86285144" style="width:20px; height:20px; cursor:pointer;">
3.3.6.1 Indident Details - Pop Up 1 - XX73qPZhxYCrzFdEQ.png3.3.6.1 Incidents for non-identified ships0.04
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86285143" style="width:20px; height:20px; cursor:pointer;">
3.3.6.1 Indident Details - Pop Up 2 - XX73qPZhxYCrzFdEQ.png3.3.6.1 Incidents for non-identified ships0.03
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86284462" style="width:20px; height:20px; cursor:pointer;">
3.3.6.1 Indident Details - Closed Fields - Pop Up.png3.3.6.1 Incidents for non-identified ships0.02
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86284461" style="width:20px; height:20px; cursor:pointer;">
3.3.6.1 Incidents for non-identified ships - Search Results.png3.3.6.1 Incidents for non-identified ships0.01
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86284460" style="width:20px; height:20px; cursor:pointer;">
3.3.6.1 Incidents for non-identified ships - Search Form.png3.3.6.1 Incidents for non-identified ships0.01
<input type="checkbox" class="attachment-checkbox" data-attachment-id="235473967" style="width:20px; height:20px; cursor:pointer;">
3.1.4.3 Application Parameters 3.png3.1.4.3 Application Parameters0.03
<input type="checkbox" class="attachment-checkbox" data-attachment-id="235473966" style="width:20px; height:20px; cursor:pointer;">
3.1.4.3 Application Parameters 2.png3.1.4.3 Application Parameters0.05
<input type="checkbox" class="attachment-checkbox" data-attachment-id="235473965" style="width:20px; height:20px; cursor:pointer;">
3.1.4.3 Application Parameters 1.png3.1.4.3 Application Parameters0.03
<input type="checkbox" class="attachment-checkbox" data-attachment-id="121807905" style="width:20px; height:20px; cursor:pointer;">
3.1.5.2.4_Received_Sent_Events_Error_Message_1.png3.1.5.2.4 Received-Sent Events Over Period Of Time0.00
<input type="checkbox" class="attachment-checkbox" data-attachment-id="268992633" style="width:20px; height:20px; cursor:pointer;">
3.3.5.5 Get Specific IR - Pop Up - Details - Export In Excel.xml3.3.5.5 Get Specific: IR0.00
<input type="checkbox" class="attachment-checkbox" data-attachment-id="198708233" style="width:20px; height:20px; cursor:pointer;">
3.3.7.1 Exemptions on Scheduled Services - Vessel Results.png3.3.7.1 Exemptions on Scheduled Services0.02
<input type="checkbox" class="attachment-checkbox" data-attachment-id="292488583" style="width:20px; height:20px; cursor:pointer;">
image-2026-7-20_16-9-10.png3.2.2.1 Create0.02
<input type="checkbox" class="attachment-checkbox" data-attachment-id="292488545" style="width:20px; height:20px; cursor:pointer;">
image-2026-7-20_14-33-34.png3.2.2.1 Create0.07
<input type="checkbox" class="attachment-checkbox" data-attachment-id="292488536" style="width:20px; height:20px; cursor:pointer;">
image-2026-7-20_14-12-21.png3.2.2.1 Create0.05
<input type="checkbox" class="attachment-checkbox" data-attachment-id="271679955" style="width:20px; height:20px; cursor:pointer;">
3.2.2.1 Incident Report - Vessel Info.png3.2.2.1 Create0.14
<input type="checkbox" class="attachment-checkbox" data-attachment-id="271679954" style="width:20px; height:20px; cursor:pointer;">
3.2.2.1 Incident Report - Create Form.png3.2.2.1 Create0.12
<input type="checkbox" class="attachment-checkbox" data-attachment-id="102832578" style="width:20px; height:20px; cursor:pointer;">
3.2.2.1 Incident Report Vessel Info - Vessel Identification.png3.2.2.1 Create0.05
<input type="checkbox" class="attachment-checkbox" data-attachment-id="102832577" style="width:20px; height:20px; cursor:pointer;">
3.2.2.1 Incident Report Vessel Info - Vessels Results.png3.2.2.1 Create0.03
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86284518" style="width:20px; height:20px; cursor:pointer;">
3.2.2.1 Waiting Distirbution Acknowledge Status of Incident Report 2.png3.2.2.1 Create0.02
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86284517" style="width:20px; height:20px; cursor:pointer;">
3.2.2.1 Waiting Distirbution Acknowledge Status of Incident Report 1.png3.2.2.1 Create0.02
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86284516" style="width:20px; height:20px; cursor:pointer;">
3.2.2.1 Select Convention - Recipients.png3.2.2.1 Create0.07
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86284515" style="width:20px; height:20px; cursor:pointer;">
3.2.2.1 Notification Processing Result.png3.2.2.1 Create0.01
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86284512" style="width:20px; height:20px; cursor:pointer;">
3.2.2.1 Incident Report - Create Form - Filled In 2.png3.2.2.1 Create0.04
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86284510" style="width:20px; height:20px; cursor:pointer;">
3.2.2.1 Incident Report - Create Form - Details 2 - Predict Plan - Distribution.png3.2.2.1 Create0.01
<input type="checkbox" class="attachment-checkbox" data-attachment-id="86284509" style="width:20px; height:20px; cursor:pointer;">
3.2.2.1 Incident Report - Create Form - Details 1.png3.2.2.1 Create0.05