diff --git a/src/webui/www/private/confirmruleclear.html b/src/webui/www/private/confirmruleclear.html index 0901365c1..8b562b257 100644 --- a/src/webui/www/private/confirmruleclear.html +++ b/src/webui/www/private/confirmruleclear.html @@ -19,7 +19,7 @@ $("cancelBtn").addEventListener("click", (e) => { e.preventDefault(); e.stopPropagation(); - window.parent.MochaUI.closeWindow(window.parent.$("clearRulesPage")); + window.parent.qBittorrent.Client.closeFrameWindow(window); }); $("confirmBtn").addEventListener("click", (e) => { e.preventDefault(); @@ -31,7 +31,7 @@ ++completionCount; if (completionCount === rules.length) { window.parent.qBittorrent.RssDownloader.updateRulesList(); - window.parent.MochaUI.closeWindow(window.parent.$("clearRulesPage")); + window.parent.qBittorrent.Client.closeFrameWindow(window); } }); }); diff --git a/src/webui/www/private/confirmruledeletion.html b/src/webui/www/private/confirmruledeletion.html index 633602c82..494e658f6 100644 --- a/src/webui/www/private/confirmruledeletion.html +++ b/src/webui/www/private/confirmruledeletion.html @@ -19,7 +19,7 @@ $("cancelBtn").addEventListener("click", (e) => { e.preventDefault(); e.stopPropagation(); - window.parent.MochaUI.closeWindow(window.parent.$("removeRulePage")); + window.parent.qBittorrent.Client.closeFrameWindow(window); }); $("confirmBtn").addEventListener("click", (e) => { e.preventDefault(); @@ -37,7 +37,7 @@ ++completionCount; if (completionCount === rules.length) { window.parent.qBittorrent.RssDownloader.updateRulesList(); - window.parent.MochaUI.closeWindow(window.parent.$("removeRulePage")); + window.parent.qBittorrent.Client.closeFrameWindow(window); } } }).send(); diff --git a/src/webui/www/private/editfeedurl.html b/src/webui/www/private/editfeedurl.html index 3ac4981ad..3a200863e 100644 --- a/src/webui/www/private/editfeedurl.html +++ b/src/webui/www/private/editfeedurl.html @@ -22,11 +22,11 @@ }, "Escape": (event) => { event.preventDefault(); - window.parent.qBittorrent.Client.closeWindow("editFeedURL"); + window.parent.qBittorrent.Client.closeFrameWindow(window); }, "Esc": (event) => { event.preventDefault(); - window.parent.qBittorrent.Client.closeWindow("editFeedURL"); + window.parent.qBittorrent.Client.closeFrameWindow(window); } } }).activate(); @@ -65,7 +65,7 @@ }, onSuccess: (response) => { window.parent.qBittorrent.Rss.updateRssFeedList(); - window.parent.qBittorrent.Client.closeWindow("editFeedURL"); + window.parent.qBittorrent.Client.closeFrameWindow(window); }, onFailure: (response) => { if (response.status === 409) diff --git a/src/webui/www/private/newrule.html b/src/webui/www/private/newrule.html index ef64c1f87..533135850 100644 --- a/src/webui/www/private/newrule.html +++ b/src/webui/www/private/newrule.html @@ -21,11 +21,11 @@ event.preventDefault(); }, "Escape": (event) => { - window.parent.MochaUI.closeWindow(window.parent.$("newRulePage")); + window.parent.qBittorrent.Client.closeFrameWindow(window); event.preventDefault(); }, "Esc": (event) => { - window.parent.MochaUI.closeWindow(window.parent.$("newRulePage")); + window.parent.qBittorrent.Client.closeFrameWindow(window); event.preventDefault(); } } @@ -52,7 +52,7 @@ }, onSuccess: (response) => { window.parent.qBittorrent.RssDownloader.updateRulesList(); - window.parent.MochaUI.closeWindow(window.parent.$("newRulePage")); + window.parent.qBittorrent.Client.closeFrameWindow(window); } }).send(); }); diff --git a/src/webui/www/private/rename_rule.html b/src/webui/www/private/rename_rule.html index 6c0acd447..66bc513b5 100644 --- a/src/webui/www/private/rename_rule.html +++ b/src/webui/www/private/rename_rule.html @@ -21,11 +21,11 @@ event.preventDefault(); }, "Escape": (event) => { - window.parent.MochaUI.closeWindow(window.parent.$("renameRulePage")); + window.parent.qBittorrent.Client.closeFrameWindow(window); event.preventDefault(); }, "Esc": (event) => { - window.parent.MochaUI.closeWindow(window.parent.$("renameRulePage")); + window.parent.qBittorrent.Client.closeFrameWindow(window); event.preventDefault(); } } @@ -63,7 +63,7 @@ }, onSuccess: (response) => { window.parent.qBittorrent.RssDownloader.updateRulesList(); - window.parent.MochaUI.closeWindow(window.parent.$("renameRulePage")); + window.parent.qBittorrent.Client.closeFrameWindow(window); } }).send(); }); diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js index 6817df461..6f0f973fc 100644 --- a/src/webui/www/private/scripts/client.js +++ b/src/webui/www/private/scripts/client.js @@ -64,15 +64,12 @@ window.qBittorrent.Client ??= (() => { } }; - const closeWindow = (windowID) => { - const window = document.getElementById(windowID); - if (!window) - return; + const closeWindow = (window) => { MochaUI.closeWindow(window); }; const closeFrameWindow = (window) => { - closeWindow(window.frameElement.closest("div.mocha").id); + MochaUI.closeWindow(window.frameElement.closest("div.mocha")); }; const getSyncMainDataInterval = () => { diff --git a/src/webui/www/private/views/confirmRecheck.html b/src/webui/www/private/views/confirmRecheck.html index b8421e77f..09aa70411 100644 --- a/src/webui/www/private/views/confirmRecheck.html +++ b/src/webui/www/private/views/confirmRecheck.html @@ -24,7 +24,9 @@ confirmText.textContent = "QBT_TR(Are you sure you want to recheck the selected torrent(s)?)QBT_TR[CONTEXT=confirmRecheckDialog]"; - cancelButton.addEventListener("click", (e) => { window.qBittorrent.Client.closeWindow("confirmRecheckDialog"); }); + cancelButton.addEventListener("click", (e) => { + window.qBittorrent.Client.closeWindow(document.getElementById("confirmRecheckDialog")); + }); confirmButton.addEventListener("click", (e) => { new Request({ url: "api/v2/torrents/recheck", @@ -34,7 +36,7 @@ }, onSuccess: () => { updateMainData(); - window.qBittorrent.Client.closeWindow("confirmRecheckDialog"); + window.qBittorrent.Client.closeWindow(document.getElementById("confirmRecheckDialog")); }, onFailure: () => { alert("QBT_TR(Unable to recheck torrents.)QBT_TR[CONTEXT=HttpServer]"); @@ -51,7 +53,7 @@ confirmButton.click(); break; case "Escape": - window.qBittorrent.Client.closeWindow("confirmRecheckDialog"); + window.qBittorrent.Client.closeWindow(document.getElementById("confirmRecheckDialog")); break; } }); diff --git a/src/webui/www/private/views/cookies.html b/src/webui/www/private/views/cookies.html index 88acfa977..677e4534b 100644 --- a/src/webui/www/private/views/cookies.html +++ b/src/webui/www/private/views/cookies.html @@ -137,7 +137,7 @@ alert(error); }, onSuccess: (response) => { - window.qBittorrent.Client.closeWindow("cookiesPage"); + window.qBittorrent.Client.closeWindow(document.getElementById("cookiesPage")); } }).send(); }; diff --git a/src/webui/www/private/views/searchplugins.html b/src/webui/www/private/views/searchplugins.html index 9b25f03fb..af9e445f0 100644 --- a/src/webui/www/private/views/searchplugins.html +++ b/src/webui/www/private/views/searchplugins.html @@ -114,7 +114,7 @@ }; const closeSearchWindow = (id) => { - window.parent.MochaUI.closeWindow(window.parent.$(id)); + window.parent.qBittorrent.Client.closeWindow(window.parent.$(id)); }; const installPlugin = (path) => {