mirror of
https://github.com/Carve/qbittorrent-webui-cjratliff.com.git
synced 2025-02-28 15:40:28 +01:00
60 lines
2.1 KiB
HTML
60 lines
2.1 KiB
HTML
<div id="confirmRecheckDialog">
|
|
<div class="genericConfirmGrid">
|
|
<span class="confirmGridItem confirmWarning"></span>
|
|
<span class="confirmGridItem dialogMessage" id="confirmRecheckMessage"></span>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<input type="button" value="Yes" id="confirmRecheckButton">
|
|
<input type="button" value="No" id="cancelRecheckButton">
|
|
</div>
|
|
|
|
<script>
|
|
"use strict";
|
|
|
|
(() => {
|
|
const confirmButton = document.getElementById("confirmRecheckButton");
|
|
const cancelButton = document.getElementById("cancelRecheckButton");
|
|
const confirmText = document.getElementById("confirmRecheckMessage");
|
|
|
|
const {
|
|
options: { data: { hashes } },
|
|
windowEl
|
|
} = window.MUI.Windows.instances["confirmRecheckDialog"];
|
|
|
|
confirmText.textContent = "Are you sure you want to recheck the selected torrent(s)?";
|
|
|
|
cancelButton.addEventListener("click", (e) => { window.qBittorrent.Client.closeWindow("confirmRecheckDialog"); });
|
|
confirmButton.addEventListener("click", (e) => {
|
|
new Request({
|
|
url: "api/v2/torrents/recheck",
|
|
method: "post",
|
|
data: {
|
|
hashes: hashes.join("|"),
|
|
},
|
|
onSuccess: function() {
|
|
updateMainData();
|
|
window.qBittorrent.Client.closeWindow("confirmRecheckDialog");
|
|
},
|
|
onFailure: function() {
|
|
alert("Unable to recheck torrents.");
|
|
}
|
|
}).send();
|
|
});
|
|
|
|
// set tabindex so window element receives keydown events
|
|
windowEl.setAttribute("tabindex", "-1");
|
|
windowEl.focus();
|
|
windowEl.addEventListener("keydown", (e) => {
|
|
switch (e.key) {
|
|
case "Enter":
|
|
confirmButton.click();
|
|
break;
|
|
case "Escape":
|
|
window.qBittorrent.Client.closeWindow("confirmRecheckDialog");
|
|
break;
|
|
}
|
|
});
|
|
})();
|
|
</script>
|