Display External IP Address in status bar
[qBittorrent.git] / src / webui / www / private / views / confirmdeletion.html
blobda2cebf50f8fc1db386fc0c9dd9c89d10b11b3ef
1 <div id="confirmDeletionDialog">
2 <div class="confirmDeletionGrid">
3 <span class="deletionGridItem confirmDialogWarning"></span>
4 <span class="deletionGridItem dialogMessage" id="deleteTorrentMessage"></span>
5 <span class="deletionGridItem">
6 <button class="disabled" type="button" id="rememberBtn" title="QBT_TR(Remember choice)QBT_TR[CONTEXT=HttpServer]" aria-label="QBT_TR(Remember choice)QBT_TR[CONTEXT=HttpServer]" disabled></button>
7 </span>
8 <span class="deletionGridItem">
9 <input type="checkbox" id="deleteFromDiskCB">
10 <label for="deleteFromDiskCB">
11 <em>QBT_TR(Also remove the content files)QBT_TR[CONTEXT=confirmDeletionDlg]</em>
12 </label>
13 </span>
14 </div>
15 </div>
16 <div>
17 <input type="button" value="QBT_TR(Remove)QBT_TR[CONTEXT=MainWindow]" id="confirmDeletionButton">
18 <input type="button" value="QBT_TR(Cancel)QBT_TR[CONTEXT=MainWindow]" id="cancelDeletionButton">
19 </div>
21 <script>
22 "use strict";
24 (() => {
25 const setRememberBtnEnabled = (enable) => {
26 rememberButton.disabled = !enable;
27 rememberButton.classList.toggle("disabled", !enable);
30 const confirmButton = document.getElementById("confirmDeletionButton");
31 const cancelButton = document.getElementById("cancelDeletionButton");
32 const rememberButton = document.getElementById("rememberBtn");
33 const deleteCB = document.getElementById("deleteFromDiskCB");
34 const deletionText = document.getElementById("deleteTorrentMessage");
36 const {
37 hashes,
38 isDeletingVisibleTorrents = false,
39 forceDeleteFiles = false,
40 } = window.MUI.Windows.instances["confirmDeletionPage"].options.data;
41 let prefDeleteContentFiles = window.qBittorrent.Cache.preferences.get().delete_torrent_content_files;
42 deleteCB.checked = forceDeleteFiles || prefDeleteContentFiles;
44 let deleteMessage;
45 if (hashes.length === 1) {
46 const { full_data: { name } } = torrentsTable.getRow(hashes[0]);
47 deleteMessage = "QBT_TR(Are you sure you want to remove %1 from the transfer list?)QBT_TR[CONTEXT=HttpServer]".replace("%1", `"${name}"`);
49 else {
50 deleteMessage = "QBT_TR(Are you sure you want to remove these %1 torrents from the transfer list?)QBT_TR[CONTEXT=HttpServer]".replace("%1", hashes.length);
53 deletionText.textContent = deleteMessage;
55 // Enable "Remember" button if the current choice is different from the saved preference
56 deleteCB.addEventListener("click", (e) => { setRememberBtnEnabled(deleteCB.checked !== prefDeleteContentFiles); });
58 // Set current "Delete files" choice as the default
59 rememberButton.addEventListener("click", (e) => {
60 window.qBittorrent.Cache.preferences.set({
61 data: {
62 "delete_torrent_content_files": deleteCB.checked
64 onSuccess: () => {
65 prefDeleteContentFiles = deleteCB.checked;
66 setRememberBtnEnabled(false);
68 });
69 });
71 cancelButton.focus();
72 cancelButton.addEventListener("click", (e) => { window.qBittorrent.Client.closeWindows(); });
74 confirmButton.addEventListener("click", (e) => {
75 // Some torrents might be removed when waiting for user input, so refetch the torrent list
76 const hashes = isDeletingVisibleTorrents
77 ? torrentsTable.getFilteredTorrentsHashes(selectedStatus, selectedCategory, selectedTag, selectedTracker)
78 : torrentsTable.selectedRowsIds();
80 new Request({
81 url: "api/v2/torrents/delete",
82 method: "post",
83 data: {
84 "hashes": hashes.join("|"),
85 "deleteFiles": deleteCB.checked
87 onSuccess: () => {
88 torrentsTable.deselectAll();
89 updateMainData();
90 updatePropertiesPanel();
91 window.qBittorrent.Client.closeWindows();
93 onFailure: () => {
94 alert("QBT_TR(Unable to delete torrents.)QBT_TR[CONTEXT=HttpServer]");
96 }).send();
97 });
98 })();
99 </script>