Enable customizing the save statistics time interval
[qBittorrent.git] / src / webui / www / private / views / confirmdeletion.html
blob122709b3f6de191c41106c6c02dbb14e110f28c2
1 <div id="confirmDeletionDialog">
2 <div class="confirmDeletionGrid">
3 <span class="deletionGridItem confirmDialogWarning"></span>
4 <span class="deletionGridItem" 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 forceDeleteFiles = false,
39 filterList = null
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: function() {
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 torrentsTable.deselectAll();
76 new Request({
77 url: "api/v2/torrents/delete",
78 method: "post",
79 data: {
80 "hashes": hashes.join("|"),
81 "deleteFiles": deleteCB.checked
83 onSuccess: function() {
84 if (filterList === "tracker")
85 setTrackerFilter(TRACKERS_ALL);
86 updateMainData();
87 window.qBittorrent.Client.closeWindows();
89 onFailure: function() {
90 alert("QBT_TR(Unable to delete torrents.)QBT_TR[CONTEXT=HttpServer]");
92 }).send();
93 });
94 })();
95 </script>