diff --git a/src/webui/www/private/addpeers.html b/src/webui/www/private/addpeers.html
index 8e00eda9b684..3110a32bed36 100644
--- a/src/webui/www/private/addpeers.html
+++ b/src/webui/www/private/addpeers.html
@@ -36,20 +36,21 @@
if (peers.length === 0)
return;
- new Request({
- url: "api/v2/torrents/addPeers",
- method: "post",
- data: {
- hashes: hash,
- peers: peers.join("|")
- },
- onFailure: () => {
- alert("QBT_TR(Unable to add peers. Please ensure you are adhering to the IP:port format.)QBT_TR[CONTEXT=HttpServer]");
- },
- onSuccess: () => {
+ fetch("api/v2/torrents/addPeers", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hashes": hash,
+ "peers": peers.join("|")
+ })
+ })
+ .then((response) => {
+ if (!response.ok) {
+ alert("QBT_TR(Unable to add peers. Please ensure you are adhering to the IP:port format.)QBT_TR[CONTEXT=HttpServer]");
+ return;
+ }
+
window.parent.qBittorrent.Client.closeFrameWindow(window);
- }
- }).send();
+ });
});
});
diff --git a/src/webui/www/private/addtrackers.html b/src/webui/www/private/addtrackers.html
index 22cdffcee557..a1c303e2f10e 100644
--- a/src/webui/www/private/addtrackers.html
+++ b/src/webui/www/private/addtrackers.html
@@ -27,18 +27,19 @@
e.preventDefault();
e.stopPropagation();
- const hash = new URI().getData("hash");
- new Request({
- url: "api/v2/torrents/addTrackers",
- method: "post",
- data: {
- hash: hash,
- urls: $("trackersUrls").value
- },
- onComplete: () => {
+ fetch("api/v2/torrents/addTrackers", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hash": new URI().getData("hash"),
+ "urls": $("trackersUrls").value
+ })
+ })
+ .then((response) => {
+ if (!response.ok)
+ return;
+
window.parent.qBittorrent.Client.closeFrameWindow(window);
- }
- }).send();
+ });
});
});
diff --git a/src/webui/www/private/addwebseeds.html b/src/webui/www/private/addwebseeds.html
index d5679b54ff09..83554a988d49 100644
--- a/src/webui/www/private/addwebseeds.html
+++ b/src/webui/www/private/addwebseeds.html
@@ -25,18 +25,20 @@
$("urls").focus();
$("addWebSeedsButton").addEventListener("click", (e) => {
e.stopPropagation();
- const hash = new URI().getData("hash");
- new Request({
- url: "api/v2/torrents/addWebSeeds",
- method: "post",
- data: {
- hash: hash,
- urls: $("urls").value.split("\n").map(w => encodeURIComponent(w.trim())).filter(w => (w.length > 0)).join("|")
- },
- onComplete: () => {
+
+ fetch("api/v2/torrents/addWebSeeds", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hash": new URI().getData("hash"),
+ "urls": $("urls").value.split("\n").map(w => encodeURIComponent(w.trim())).filter(w => (w.length > 0)).join("|")
+ })
+ })
+ .then((response) => {
+ if (!response.ok)
+ return;
+
window.parent.qBittorrent.Client.closeFrameWindow(window);
- }
- }).send();
+ });
});
});
diff --git a/src/webui/www/private/confirmfeeddeletion.html b/src/webui/www/private/confirmfeeddeletion.html
index 52bda6c4814c..e8d36e056b3e 100644
--- a/src/webui/www/private/confirmfeeddeletion.html
+++ b/src/webui/www/private/confirmfeeddeletion.html
@@ -26,20 +26,22 @@
let completionCount = 0;
paths.forEach((path) => {
- new Request({
- url: "api/v2/rss/removeItem",
- method: "post",
- data: {
- path: decodeURIComponent(path)
- },
- onComplete: (response) => {
+ fetch("api/v2/rss/removeItem", {
+ method: "POST",
+ body: new URLSearchParams({
+ "path": decodeURIComponent(path)
+ })
+ })
+ .then((response) => {
+ if (!response.ok)
+ return;
+
++completionCount;
if (completionCount === paths.length) {
window.parent.qBittorrent.Rss.updateRssFeedList();
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
- }
- }).send();
+ });
});
});
});
diff --git a/src/webui/www/private/confirmruledeletion.html b/src/webui/www/private/confirmruledeletion.html
index 494e658f6e0e..812b3eb64d72 100644
--- a/src/webui/www/private/confirmruledeletion.html
+++ b/src/webui/www/private/confirmruledeletion.html
@@ -27,20 +27,22 @@
let completionCount = 0;
rules.forEach((rule) => {
- new Request({
- url: "api/v2/rss/removeRule",
- method: "post",
- data: {
- ruleName: decodeURIComponent(rule)
- },
- onComplete: (response) => {
+ fetch("api/v2/rss/removeRule", {
+ method: "POST",
+ body: new URLSearchParams({
+ "ruleName": decodeURIComponent(rule)
+ })
+ })
+ .then((response) => {
+ if (!response.ok)
+ return;
+
++completionCount;
if (completionCount === rules.length) {
window.parent.qBittorrent.RssDownloader.updateRulesList();
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
- }
- }).send();
+ });
});
});
});
diff --git a/src/webui/www/private/confirmtrackerdeletion.html b/src/webui/www/private/confirmtrackerdeletion.html
index 673595f5fc25..790931d3d394 100644
--- a/src/webui/www/private/confirmtrackerdeletion.html
+++ b/src/webui/www/private/confirmtrackerdeletion.html
@@ -24,18 +24,20 @@
});
$("confirmBtn").addEventListener("click", (e) => {
e.stopPropagation();
- const cmd = "api/v2/torrents/removeTrackers";
- new Request({
- url: cmd,
- method: "post",
- data: {
- hash: "*",
- urls: urls,
- },
- onComplete: () => {
+
+ fetch("api/v2/torrents/removeTrackers", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hash": "*",
+ "urls": urls
+ })
+ })
+ .then((response) => {
+ if (!response.ok)
+ return;
+
window.parent.qBittorrent.Client.closeFrameWindow(window);
- }
- }).send();
+ });
});
});
diff --git a/src/webui/www/private/downloadlimit.html b/src/webui/www/private/downloadlimit.html
index 62ac3e750756..296edbc230c8 100644
--- a/src/webui/www/private/downloadlimit.html
+++ b/src/webui/www/private/downloadlimit.html
@@ -50,30 +50,34 @@
const setDlLimit = () => {
const limit = Number($("dllimitUpdatevalue").value) * 1024;
if (hashes[0] === "global") {
- new Request({
- url: "api/v2/transfer/setDownloadLimit",
- method: "post",
- data: {
- "limit": limit
- },
- onComplete: () => {
+ fetch("api/v2/transfer/setDownloadLimit", {
+ method: "POST",
+ body: new URLSearchParams({
+ "limit": limit
+ })
+ })
+ .then(async (response) => {
+ if (!response.ok)
+ return;
+
window.parent.updateMainData();
window.parent.qBittorrent.Client.closeFrameWindow(window);
- }
- }).send();
+ });
}
else {
- new Request({
- url: "api/v2/torrents/setDownloadLimit",
- method: "post",
- data: {
- "hashes": hashes.join("|"),
- "limit": limit
- },
- onComplete: () => {
+ fetch("api/v2/torrents/setDownloadLimit", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hashes": hashes.join("|"),
+ "limit": limit
+ })
+ })
+ .then(async (response) => {
+ if (!response.ok)
+ return;
+
window.parent.qBittorrent.Client.closeFrameWindow(window);
- }
- }).send();
+ });
}
};
diff --git a/src/webui/www/private/editfeedurl.html b/src/webui/www/private/editfeedurl.html
index fd97fc4770c5..314bc7c7e3c7 100644
--- a/src/webui/www/private/editfeedurl.html
+++ b/src/webui/www/private/editfeedurl.html
@@ -51,25 +51,25 @@
$("submitButton").disabled = true;
- new Request({
- url: "api/v2/rss/setFeedURL",
- method: "post",
- data: {
- path: new URI().getData("path"),
- url: newUrl
- },
- onSuccess: (response) => {
+ fetch("api/v2/rss/setFeedURL", {
+ method: "POST",
+ body: new URLSearchParams({
+ "path": new URI().getData("path"),
+ "url": newUrl
+ })
+ })
+ .then(async (response) => {
+ if (!response.ok) {
+ alert((response.status === 409)
+ ? await response.text()
+ : "QBT_TR(Unable to update URL)QBT_TR[CONTEXT=RSSWidget]");
+ $("submitButton").disabled = false;
+ return;
+ }
+
window.parent.qBittorrent.Rss.updateRssFeedList();
window.parent.qBittorrent.Client.closeFrameWindow(window);
- },
- onFailure: (response) => {
- if (response.status === 409)
- alert(response.responseText);
- else
- alert("QBT_TR(Unable to update URL)QBT_TR[CONTEXT=RSSWidget]");
- $("submitButton").disabled = false;
- }
- }).send();
+ });
});
});
diff --git a/src/webui/www/private/edittracker.html b/src/webui/www/private/edittracker.html
index 38a3b0408954..d8591ef5587b 100644
--- a/src/webui/www/private/edittracker.html
+++ b/src/webui/www/private/edittracker.html
@@ -37,19 +37,20 @@
e.preventDefault();
e.stopPropagation();
- const hash = new URI().getData("hash");
- new Request({
- url: "api/v2/torrents/editTracker",
- method: "post",
- data: {
- hash: hash,
- origUrl: currentUrl,
- newUrl: $("trackerUrl").value
- },
- onComplete: () => {
+ fetch("api/v2/torrents/editTracker", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hash": new URI().getData("hash"),
+ "origUrl": currentUrl,
+ "newUrl": $("trackerUrl").value
+ })
+ })
+ .then((response) => {
+ if (!response.ok)
+ return;
+
window.parent.qBittorrent.Client.closeFrameWindow(window);
- }
- }).send();
+ });
});
});
diff --git a/src/webui/www/private/editwebseed.html b/src/webui/www/private/editwebseed.html
index 82bcba089224..99f071fe4819 100644
--- a/src/webui/www/private/editwebseed.html
+++ b/src/webui/www/private/editwebseed.html
@@ -32,19 +32,21 @@
$("editWebSeedButton").addEventListener("click", (e) => {
e.stopPropagation();
- const hash = new URI().getData("hash");
- new Request({
- url: "api/v2/torrents/editWebSeed",
- method: "post",
- data: {
- hash: hash,
- origUrl: origUrl,
- newUrl: encodeURIComponent($("url").value.trim()),
- },
- onComplete: () => {
+
+ fetch("api/v2/torrents/editWebSeed", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hash": new URI().getData("hash"),
+ "origUrl": origUrl,
+ "newUrl": encodeURIComponent($("url").value.trim())
+ })
+ })
+ .then((response) => {
+ if (!response.ok)
+ return;
+
window.parent.qBittorrent.Client.closeFrameWindow(window);
- }
- }).send();
+ });
});
});
diff --git a/src/webui/www/private/newcategory.html b/src/webui/www/private/newcategory.html
index f2b6d27d5bbb..b55ab24244b5 100644
--- a/src/webui/www/private/newcategory.html
+++ b/src/webui/www/private/newcategory.html
@@ -72,72 +72,77 @@
if ((uriHashes === "") || !verifyCategoryName(categoryName))
return;
- new Request({
- url: "api/v2/torrents/createCategory",
- method: "post",
- data: {
- category: categoryName,
- savePath: savePath
- },
- onSuccess: () => {
- new Request({
- url: "api/v2/torrents/setCategory",
- method: "post",
- data: {
- hashes: uriHashes,
- category: categoryName
- },
- onSuccess: () => {
+ fetch("api/v2/torrents/createCategory", {
+ method: "POST",
+ body: new URLSearchParams({
+ "category": categoryName,
+ "savePath": savePath
+ })
+ })
+ .then((response) => {
+ if (!response.ok) {
+ alert("QBT_TR(Unable to create category)QBT_TR[CONTEXT=Category] " + window.qBittorrent.Misc.escapeHtml(categoryName));
+ return;
+ }
+
+ fetch("api/v2/torrents/setCategory", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hashes": uriHashes,
+ "category": categoryName
+ })
+ })
+ .then((response) => {
+ if (!response.ok) {
+ alert("QBT_TR(Unable to set category)QBT_TR[CONTEXT=Category]");
+ return;
+ }
+
window.parent.updateMainData();
window.parent.qBittorrent.Client.closeFrameWindow(window);
- },
- onFailure: () => {
- alert("QBT_TR(Unable to set category)QBT_TR[CONTEXT=Category]");
- }
- }).send();
- },
- onFailure: () => {
- alert("QBT_TR(Unable to create category)QBT_TR[CONTEXT=Category] " + window.qBittorrent.Misc.escapeHtml(categoryName));
- }
- }).send();
+ });
+ });
break;
+
case "create":
case "createSubcategory":
if (!verifyCategoryName(categoryName))
return;
+ fetch("api/v2/torrents/createCategory", {
+ method: "POST",
+ body: new URLSearchParams({
+ "category": categoryName,
+ "savePath": savePath
+ })
+ })
+ .then((response) => {
+ if (!response.ok) {
+ alert("QBT_TR(Unable to create category)QBT_TR[CONTEXT=Category]");
+ return;
+ }
- new Request({
- url: "api/v2/torrents/createCategory",
- method: "post",
- data: {
- category: categoryName,
- savePath: savePath
- },
- onSuccess: () => {
window.parent.updateMainData();
window.parent.qBittorrent.Client.closeFrameWindow(window);
- },
- onFailure: () => {
- alert("QBT_TR(Unable to create category)QBT_TR[CONTEXT=Category]");
- }
- }).send();
+ });
break;
+
case "edit":
- new Request({
- url: "api/v2/torrents/editCategory",
- method: "post",
- data: {
- category: uriCategoryName, // category name can't be changed
- savePath: savePath
- },
- onSuccess: () => {
+ fetch("api/v2/torrents/editCategory", {
+ method: "POST",
+ body: new URLSearchParams({
+ "category": uriCategoryName, // category name can't be changed
+ "savePath": savePath
+ })
+ })
+ .then((response) => {
+ if (!response.ok) {
+ alert("QBT_TR(Unable to edit category)QBT_TR[CONTEXT=Category]");
+ return;
+ }
+
window.parent.updateMainData();
window.parent.qBittorrent.Client.closeFrameWindow(window);
- },
- onFailure: () => {
- alert("QBT_TR(Unable to edit category)QBT_TR[CONTEXT=Category]");
- }
- }).send();
+ });
break;
}
});
diff --git a/src/webui/www/private/newfeed.html b/src/webui/www/private/newfeed.html
index 999c1c07cf79..5197189af59e 100644
--- a/src/webui/www/private/newfeed.html
+++ b/src/webui/www/private/newfeed.html
@@ -42,23 +42,24 @@
$("submitButton").disabled = true;
- new Request({
- url: "api/v2/rss/addFeed",
- method: "post",
- data: {
- url: feedURL,
- path: path ? (path + "\\" + feedURL) : ""
- },
- onSuccess: (response) => {
+ fetch("api/v2/rss/addFeed", {
+ method: "POST",
+ body: new URLSearchParams({
+ "url": feedURL,
+ "path": path ? (path + "\\" + feedURL) : ""
+ })
+ })
+ .then(async (response) => {
+ if (!response.ok) {
+ if (response.status === 409)
+ alert(await response.text());
+ $("submitButton").disabled = false;
+ return;
+ }
+
window.parent.qBittorrent.Rss.updateRssFeedList();
window.parent.qBittorrent.Client.closeFrameWindow(window);
- },
- onFailure: (response) => {
- if (response.status === 409)
- alert(response.responseText);
- $("submitButton").disabled = false;
- }
- }).send();
+ });
});
});
diff --git a/src/webui/www/private/newfolder.html b/src/webui/www/private/newfolder.html
index 463a6fdc8513..26ee91fb23f3 100644
--- a/src/webui/www/private/newfolder.html
+++ b/src/webui/www/private/newfolder.html
@@ -43,22 +43,23 @@
$("submitButton").disabled = true;
- new Request({
- url: "api/v2/rss/addFolder",
- method: "post",
- data: {
- path: path ? (path + "\\" + folderName) : folderName
- },
- onSuccess: (response) => {
+ fetch("api/v2/rss/addFolder", {
+ method: "POST",
+ body: new URLSearchParams({
+ "path": path ? (path + "\\" + folderName) : folderName
+ })
+ })
+ .then(async (response) => {
+ if (!response.ok) {
+ if (response.status === 409)
+ alert(await response.text());
+ $("submitButton").disabled = false;
+ return;
+ }
+
window.parent.qBittorrent.Rss.updateRssFeedList();
window.parent.qBittorrent.Client.closeFrameWindow(window);
- },
- onFailure: (response) => {
- if (response.status === 409)
- alert(response.responseText);
- $("submitButton").disabled = false;
- }
- }).send();
+ });
});
});
diff --git a/src/webui/www/private/newrule.html b/src/webui/www/private/newrule.html
index acf6714c5346..4f7d9d0504a1 100644
--- a/src/webui/www/private/newrule.html
+++ b/src/webui/www/private/newrule.html
@@ -39,18 +39,21 @@
return;
}
$("submitButton").disabled = true;
- new Request({
- url: "api/v2/rss/setRule",
- method: "post",
- data: {
- ruleName: name,
- ruleDef: "{}"
- },
- onSuccess: (response) => {
+
+ fetch("api/v2/rss/setRule", {
+ method: "POST",
+ body: new URLSearchParams({
+ "ruleName": name,
+ "ruleDef": "{}"
+ })
+ })
+ .then((response) => {
+ if (!response.ok)
+ return;
+
window.parent.qBittorrent.RssDownloader.updateRulesList();
window.parent.qBittorrent.Client.closeFrameWindow(window);
- }
- }).send();
+ });
});
});
diff --git a/src/webui/www/private/newtag.html b/src/webui/www/private/newtag.html
index 1b98e29bbc5f..55a4d0c7082f 100644
--- a/src/webui/www/private/newtag.html
+++ b/src/webui/www/private/newtag.html
@@ -56,33 +56,37 @@
if (uriHashes === "")
return;
- new Request({
- url: "api/v2/torrents/addTags",
- method: "post",
- data: {
- hashes: uriHashes,
- tags: tagName,
- },
- onComplete: () => {
+ fetch("api/v2/torrents/addTags", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hashes": uriHashes,
+ "tags": tagName
+ })
+ })
+ .then(async (response) => {
+ if (!response.ok)
+ return;
+
window.parent.qBittorrent.Client.closeFrameWindow(window);
- }
- }).send();
+ });
break;
case "create":
if (!verifyTagName(tagName))
return;
- new Request({
- url: "api/v2/torrents/createTags",
- method: "post",
- data: {
- tags: tagName,
- },
- onComplete: () => {
+ fetch("api/v2/torrents/createTags", {
+ method: "POST",
+ body: new URLSearchParams({
+ "tags": tagName
+ })
+ })
+ .then(async (response) => {
+ if (!response.ok)
+ return;
+
window.parent.qBittorrent.Client.closeFrameWindow(window);
- }
- }).send();
+ });
break;
}
});
diff --git a/src/webui/www/private/rename.html b/src/webui/www/private/rename.html
index 445fad207659..b37206d79c50 100644
--- a/src/webui/www/private/rename.html
+++ b/src/webui/www/private/rename.html
@@ -44,17 +44,19 @@
const hash = new URI().getData("hash");
if (hash) {
- new Request({
- url: "api/v2/torrents/rename",
- method: "post",
- data: {
- hash: hash,
- name: name
- },
- onComplete: () => {
+ fetch("api/v2/torrents/rename", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hash": hash,
+ "name": name
+ })
+ })
+ .then((response) => {
+ if (!response.ok)
+ return;
+
window.parent.qBittorrent.Client.closeFrameWindow(window);
- }
- }).send();
+ });
}
});
});
diff --git a/src/webui/www/private/rename_feed.html b/src/webui/www/private/rename_feed.html
index 90fef405f6a6..acceff8642e8 100644
--- a/src/webui/www/private/rename_feed.html
+++ b/src/webui/www/private/rename_feed.html
@@ -51,23 +51,24 @@
$("renameButton").disabled = true;
- new Request({
- url: "api/v2/rss/moveItem",
- method: "post",
- data: {
- itemPath: oldPath,
- destPath: newPath
- },
- onSuccess: (response) => {
+ fetch("api/v2/rss/moveItem", {
+ method: "POST",
+ body: new URLSearchParams({
+ "itemPath": oldPath,
+ "destPath": newPath
+ })
+ })
+ .then(async (response) => {
+ if (!response.ok) {
+ if (response.status === 409)
+ alert(await response.text());
+ $("renameButton").disabled = false;
+ return;
+ }
+
window.parent.qBittorrent.Rss.updateRssFeedList();
window.parent.qBittorrent.Client.closeFrameWindow(window);
- },
- onFailure: (response) => {
- if (response.status === 409)
- alert(response.responseText);
- $("renameButton").disabled = false;
- }
- }).send();
+ });
});
});
diff --git a/src/webui/www/private/rename_file.html b/src/webui/www/private/rename_file.html
index a7b4c5a46b59..5333d4bb2dd5 100644
--- a/src/webui/www/private/rename_file.html
+++ b/src/webui/www/private/rename_file.html
@@ -60,22 +60,23 @@
const newPath = parentPath
? parentPath + window.qBittorrent.Filesystem.PathSeparator + newName
: newName;
- new Request({
- url: isFolder ? "api/v2/torrents/renameFolder" : "api/v2/torrents/renameFile",
- method: "post",
- data: {
- hash: hash,
- oldPath: oldPath,
- newPath: newPath
- },
- onSuccess: () => {
+ fetch((isFolder ? "api/v2/torrents/renameFolder" : "api/v2/torrents/renameFile"), {
+ method: "POST",
+ body: new URLSearchParams({
+ "hash": hash,
+ "oldPath": oldPath,
+ "newPath": newPath
+ })
+ })
+ .then((response) => {
+ if (!response.ok) {
+ alert("QBT_TR(Failed to update name)QBT_TR[CONTEXT=HttpServer]");
+ $("renameButton").disabled = false;
+ return;
+ }
+
window.parent.qBittorrent.Client.closeFrameWindow(window);
- },
- onFailure: () => {
- alert("QBT_TR(Failed to update name)QBT_TR[CONTEXT=HttpServer]");
- $("renameButton").disabled = false;
- }
- }).send();
+ });
});
});
diff --git a/src/webui/www/private/rename_files.html b/src/webui/www/private/rename_files.html
index 588296ed78d9..d16f75e9bd47 100644
--- a/src/webui/www/private/rename_files.html
+++ b/src/webui/www/private/rename_files.html
@@ -379,17 +379,20 @@
};
const setupTable = (selectedRows) => {
- new Request.JSON({
- url: new URI("api/v2/torrents/files?hash=" + data.hash),
- noCache: true,
- method: "get",
- onSuccess: (files) => {
+ fetch(new URI("api/v2/torrents/files").setData("hash", data.hash), {
+ method: "GET",
+ cache: "no-store"
+ })
+ .then(async (response) => {
+ if (!response.ok)
+ return;
+
+ const files = await response.json();
if (files.length === 0)
bulkRenameFilesTable.clear();
else
handleTorrentFiles(files, selectedRows);
- }
- }).send();
+ });
};
setupTable(data.selectedRows);
})();
diff --git a/src/webui/www/private/rename_rule.html b/src/webui/www/private/rename_rule.html
index 5f97ad9c3112..7a079471a00b 100644
--- a/src/webui/www/private/rename_rule.html
+++ b/src/webui/www/private/rename_rule.html
@@ -50,18 +50,21 @@
}
$("renameButton").disabled = true;
- new Request({
- url: "api/v2/rss/renameRule",
- method: "post",
- data: {
- ruleName: oldName,
- newRuleName: newName
- },
- onSuccess: (response) => {
+
+ fetch("api/v2/rss/renameRule", {
+ method: "POST",
+ body: new URLSearchParams({
+ "ruleName": oldName,
+ "newRuleName": newName
+ })
+ })
+ .then((response) => {
+ if (!response.ok)
+ return;
+
window.parent.qBittorrent.RssDownloader.updateRulesList();
window.parent.qBittorrent.Client.closeFrameWindow(window);
- }
- }).send();
+ });
});
});
diff --git a/src/webui/www/private/scripts/cache.js b/src/webui/www/private/scripts/cache.js
index 4d2ac096c4ac..0873ef974754 100644
--- a/src/webui/www/private/scripts/cache.js
+++ b/src/webui/www/private/scripts/cache.js
@@ -62,8 +62,7 @@ window.qBittorrent.Cache ??= (() => {
if (!response.ok)
return;
- const responseText = await response.text();
- const responseJSON = JSON.parse(responseText);
+ const responseJSON = await response.json();
deepFreeze(responseJSON);
this.#m_store = responseJSON;
});
diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js
index e360429623ba..60ce5103ac81 100644
--- a/src/webui/www/private/scripts/client.js
+++ b/src/webui/www/private/scripts/client.js
@@ -748,199 +748,199 @@ window.addEventListener("DOMContentLoaded", () => {
let syncMainDataTimeoutID = -1;
let syncRequestInProgress = false;
const syncMainData = () => {
- const url = new URI("api/v2/sync/maindata");
- url.setData("rid", syncMainDataLastResponseId);
- const request = new Request.JSON({
- url: url,
- noCache: true,
- method: "get",
- onFailure: () => {
- const errorDiv = $("error_div");
- if (errorDiv)
- errorDiv.textContent = "QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]";
- syncRequestInProgress = false;
- syncData(2000);
- },
- onSuccess: (response) => {
- $("error_div").textContent = "";
- if (response) {
- clearTimeout(torrentsFilterInputTimer);
- torrentsFilterInputTimer = -1;
-
- let torrentsTableSelectedRows;
- let updateStatuses = false;
- let update_categories = false;
- let updateTags = false;
- let updateTrackers = false;
- let updateTorrents = false;
- const full_update = (response["full_update"] === true);
- if (full_update) {
- torrentsTableSelectedRows = torrentsTable.selectedRowsIds();
- updateStatuses = true;
- update_categories = true;
- updateTags = true;
- updateTrackers = true;
- updateTorrents = true;
- torrentsTable.clear();
- category_list.clear();
- tagList.clear();
- trackerList.clear();
- }
- if (response["rid"])
- syncMainDataLastResponseId = response["rid"];
- if (response["categories"]) {
- for (const key in response["categories"]) {
- if (!Object.hasOwn(response["categories"], key))
- continue;
-
- const responseCategory = response["categories"][key];
- const categoryHash = window.qBittorrent.Misc.genHash(key);
- const category = category_list.get(categoryHash);
- if (category !== undefined) {
- // only the save path can change for existing categories
- category.savePath = responseCategory.savePath;
- }
- else {
- category_list.set(categoryHash, {
- name: responseCategory.name,
- savePath: responseCategory.savePath,
- torrents: new Set()
- });
+ syncRequestInProgress = true;
+ fetch(new URI("api/v2/sync/maindata").setData("rid", syncMainDataLastResponseId), {
+ method: "GET",
+ cache: "no-store"
+ })
+ .then(async (response) => {
+ if (response.ok) {
+ $("error_div").textContent = "";
+
+ const responseJSON = await response.json();
+
+ clearTimeout(torrentsFilterInputTimer);
+ torrentsFilterInputTimer = -1;
+
+ let torrentsTableSelectedRows;
+ let updateStatuses = false;
+ let update_categories = false;
+ let updateTags = false;
+ let updateTrackers = false;
+ let updateTorrents = false;
+ const fullUpdate = (responseJSON["fullUpdate"] === true);
+ if (fullUpdate) {
+ torrentsTableSelectedRows = torrentsTable.selectedRowsIds();
+ updateStatuses = true;
+ update_categories = true;
+ updateTags = true;
+ updateTrackers = true;
+ updateTorrents = true;
+ torrentsTable.clear();
+ category_list.clear();
+ tagList.clear();
+ trackerList.clear();
+ }
+ if (responseJSON["rid"])
+ syncMainDataLastResponseId = responseJSON["rid"];
+ if (responseJSON["categories"]) {
+ for (const key in responseJSON["categories"]) {
+ if (!Object.hasOwn(responseJSON["categories"], key))
+ continue;
+
+ const responseCategory = responseJSON["categories"][key];
+ const categoryHash = window.qBittorrent.Misc.genHash(key);
+ const category = category_list.get(categoryHash);
+ if (category !== undefined) {
+ // only the save path can change for existing categories
+ category.savePath = responseCategory.savePath;
+ }
+ else {
+ category_list.set(categoryHash, {
+ name: responseCategory.name,
+ savePath: responseCategory.savePath,
+ torrents: new Set()
+ });
+ }
}
+ update_categories = true;
}
- update_categories = true;
- }
- if (response["categories_removed"]) {
- response["categories_removed"].each((category) => {
- const categoryHash = window.qBittorrent.Misc.genHash(category);
- category_list.delete(categoryHash);
- });
- update_categories = true;
- }
- if (response["tags"]) {
- for (const tag of response["tags"]) {
- const tagHash = window.qBittorrent.Misc.genHash(tag);
- if (!tagList.has(tagHash)) {
- tagList.set(tagHash, {
- name: tag,
- torrents: new Set()
- });
+ if (responseJSON["categories_removed"]) {
+ responseJSON["categories_removed"].each((category) => {
+ const categoryHash = window.qBittorrent.Misc.genHash(category);
+ category_list.delete(categoryHash);
+ });
+ update_categories = true;
+ }
+ if (responseJSON["tags"]) {
+ for (const tag of responseJSON["tags"]) {
+ const tagHash = window.qBittorrent.Misc.genHash(tag);
+ if (!tagList.has(tagHash)) {
+ tagList.set(tagHash, {
+ name: tag,
+ torrents: new Set()
+ });
+ }
}
+ updateTags = true;
}
- updateTags = true;
- }
- if (response["tags_removed"]) {
- for (let i = 0; i < response["tags_removed"].length; ++i) {
- const tagHash = window.qBittorrent.Misc.genHash(response["tags_removed"][i]);
- tagList.delete(tagHash);
+ if (responseJSON["tags_removed"]) {
+ for (let i = 0; i < responseJSON["tags_removed"].length; ++i) {
+ const tagHash = window.qBittorrent.Misc.genHash(responseJSON["tags_removed"][i]);
+ tagList.delete(tagHash);
+ }
+ updateTags = true;
}
- updateTags = true;
- }
- if (response["trackers"]) {
- for (const [tracker, torrents] of Object.entries(response["trackers"])) {
- const host = window.qBittorrent.Misc.getHost(tracker);
- const hash = window.qBittorrent.Misc.genHash(host);
-
- let trackerListItem = trackerList.get(hash);
- if (trackerListItem === undefined) {
- trackerListItem = { host: host, trackerTorrentMap: new Map() };
- trackerList.set(hash, trackerListItem);
+ if (responseJSON["trackers"]) {
+ for (const [tracker, torrents] of Object.entries(responseJSON["trackers"])) {
+ const host = window.qBittorrent.Misc.getHost(tracker);
+ const hash = window.qBittorrent.Misc.genHash(host);
+
+ let trackerListItem = trackerList.get(hash);
+ if (trackerListItem === undefined) {
+ trackerListItem = { host: host, trackerTorrentMap: new Map() };
+ trackerList.set(hash, trackerListItem);
+ }
+ trackerListItem.trackerTorrentMap.set(tracker, new Set(torrents));
}
- trackerListItem.trackerTorrentMap.set(tracker, new Set(torrents));
+ updateTrackers = true;
}
- updateTrackers = true;
- }
- if (response["trackers_removed"]) {
- for (let i = 0; i < response["trackers_removed"].length; ++i) {
- const tracker = response["trackers_removed"][i];
- const host = window.qBittorrent.Misc.getHost(tracker);
- const hash = window.qBittorrent.Misc.genHash(host);
- const trackerListEntry = trackerList.get(hash);
- if (trackerListEntry) {
- trackerListEntry.trackerTorrentMap.delete(tracker);
- // Remove unused trackers
- if (trackerListEntry.trackerTorrentMap.size === 0) {
- trackerList.delete(hash);
- if (selectedTracker === hash) {
- selectedTracker = TRACKERS_ALL;
- LocalPreferences.set("selected_tracker", selectedTracker.toString());
+ if (responseJSON["trackers_removed"]) {
+ for (let i = 0; i < responseJSON["trackers_removed"].length; ++i) {
+ const tracker = responseJSON["trackers_removed"][i];
+ const host = window.qBittorrent.Misc.getHost(tracker);
+ const hash = window.qBittorrent.Misc.genHash(host);
+ const trackerListEntry = trackerList.get(hash);
+ if (trackerListEntry) {
+ trackerListEntry.trackerTorrentMap.delete(tracker);
+ // Remove unused trackers
+ if (trackerListEntry.trackerTorrentMap.size === 0) {
+ trackerList.delete(hash);
+ if (selectedTracker === hash) {
+ selectedTracker = TRACKERS_ALL;
+ LocalPreferences.set("selected_tracker", selectedTracker.toString());
+ }
}
}
}
+ updateTrackers = true;
}
- updateTrackers = true;
- }
- if (response["torrents"]) {
- for (const key in response["torrents"]) {
- if (!Object.hasOwn(response["torrents"], key))
- continue;
-
- response["torrents"][key]["hash"] = key;
- response["torrents"][key]["rowId"] = key;
- if (response["torrents"][key]["state"]) {
- const state = response["torrents"][key]["state"];
- response["torrents"][key]["status"] = state;
- response["torrents"][key]["_statusOrder"] = statusSortOrder[state];
- updateStatuses = true;
+ if (responseJSON["torrents"]) {
+ for (const key in responseJSON["torrents"]) {
+ if (!Object.hasOwn(responseJSON["torrents"], key))
+ continue;
+
+ responseJSON["torrents"][key]["hash"] = key;
+ responseJSON["torrents"][key]["rowId"] = key;
+ if (responseJSON["torrents"][key]["state"]) {
+ const state = responseJSON["torrents"][key]["state"];
+ responseJSON["torrents"][key]["status"] = state;
+ responseJSON["torrents"][key]["_statusOrder"] = statusSortOrder[state];
+ updateStatuses = true;
+ }
+ torrentsTable.updateRowData(responseJSON["torrents"][key]);
+ if (addTorrentToCategoryList(responseJSON["torrents"][key]))
+ update_categories = true;
+ if (addTorrentToTagList(responseJSON["torrents"][key]))
+ updateTags = true;
+ updateTorrents = true;
}
- torrentsTable.updateRowData(response["torrents"][key]);
- if (addTorrentToCategoryList(response["torrents"][key]))
- update_categories = true;
- if (addTorrentToTagList(response["torrents"][key]))
- updateTags = true;
+ }
+ if (responseJSON["torrents_removed"]) {
+ responseJSON["torrents_removed"].each((hash) => {
+ torrentsTable.removeRow(hash);
+ removeTorrentFromCategoryList(hash);
+ update_categories = true; // Always to update All category
+ removeTorrentFromTagList(hash);
+ updateTags = true; // Always to update All tag
+ });
updateTorrents = true;
+ updateStatuses = true;
}
- }
- if (response["torrents_removed"]) {
- response["torrents_removed"].each((hash) => {
- torrentsTable.removeRow(hash);
- removeTorrentFromCategoryList(hash);
- update_categories = true; // Always to update All category
- removeTorrentFromTagList(hash);
- updateTags = true; // Always to update All tag
- });
- updateTorrents = true;
- updateStatuses = true;
- }
- // don't update the table unnecessarily
- if (updateTorrents)
- torrentsTable.updateTable(full_update);
+ // don't update the table unnecessarily
+ if (updateTorrents)
+ torrentsTable.updateTable(fullUpdate);
- if (response["server_state"]) {
- const tmp = response["server_state"];
- for (const k in tmp) {
- if (!Object.hasOwn(tmp, k))
- continue;
- serverState[k] = tmp[k];
+ if (responseJSON["server_state"]) {
+ const tmp = responseJSON["server_state"];
+ for (const k in tmp) {
+ if (!Object.hasOwn(tmp, k))
+ continue;
+ serverState[k] = tmp[k];
+ }
+ processServerState();
}
- processServerState();
- }
- if (updateStatuses)
- updateFiltersList();
+ if (updateStatuses)
+ updateFiltersList();
- if (update_categories) {
- updateCategoryList();
- window.qBittorrent.TransferList.contextMenu.updateCategoriesSubMenu(category_list);
- }
- if (updateTags) {
- updateTagList();
- window.qBittorrent.TransferList.contextMenu.updateTagsSubMenu(tagList);
+ if (update_categories) {
+ updateCategoryList();
+ window.qBittorrent.TransferList.contextMenu.updateCategoriesSubMenu(category_list);
+ }
+ if (updateTags) {
+ updateTagList();
+ window.qBittorrent.TransferList.contextMenu.updateTagsSubMenu(tagList);
+ }
+ if (updateTrackers)
+ updateTrackerList();
+
+ if (fullUpdate)
+ // re-select previously selected rows
+ torrentsTable.reselectRows(torrentsTableSelectedRows);
}
- if (updateTrackers)
- updateTrackerList();
- if (full_update)
- // re-select previously selected rows
- torrentsTable.reselectRows(torrentsTableSelectedRows);
- }
- syncRequestInProgress = false;
- syncData(window.qBittorrent.Client.getSyncMainDataInterval());
- }
- });
- syncRequestInProgress = true;
- request.send();
+ syncRequestInProgress = false;
+ syncData(window.qBittorrent.Client.getSyncMainDataInterval());
+ },
+ (error) => {
+ const errorDiv = $("error_div");
+ if (errorDiv)
+ errorDiv.textContent = "QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]";
+ syncRequestInProgress = false;
+ syncData(2000);
+ });
};
updateMainData = () => {
@@ -1101,18 +1101,19 @@ window.addEventListener("DOMContentLoaded", () => {
// Change icon immediately to give some feedback
updateAltSpeedIcon(!alternativeSpeedLimits);
- new Request({
- url: "api/v2/transfer/toggleSpeedLimitsMode",
- method: "post",
- onComplete: () => {
+ fetch("api/v2/transfer/toggleSpeedLimitsMode", {
+ method: "POST"
+ })
+ .then((response) => {
+ if (!response.ok) {
+ // Restore icon in case of failure
+ updateAltSpeedIcon(alternativeSpeedLimits);
+ return;
+ }
+
alternativeSpeedLimits = !alternativeSpeedLimits;
updateMainData();
- },
- onFailure: () => {
- // Restore icon in case of failure
- updateAltSpeedIcon(alternativeSpeedLimits);
- }
- }).send();
+ });
});
$("DlInfos").addEventListener("click", () => { globalDownloadLimitFN(); });
diff --git a/src/webui/www/private/scripts/download.js b/src/webui/www/private/scripts/download.js
index 1bbbddea5c27..e175d02ea0ef 100644
--- a/src/webui/www/private/scripts/download.js
+++ b/src/webui/www/private/scripts/download.js
@@ -36,26 +36,28 @@ window.qBittorrent.Download ??= (() => {
let defaultSavePath = "";
const getCategories = () => {
- new Request.JSON({
- url: "api/v2/torrents/categories",
- method: "get",
- noCache: true,
- onSuccess: (data) => {
- if (data) {
- categories = data;
- for (const i in data) {
- if (!Object.hasOwn(data, i))
- continue;
-
- const category = data[i];
- const option = document.createElement("option");
- option.value = category.name;
- option.textContent = category.name;
- $("categorySelect").appendChild(option);
- }
+ fetch("api/v2/torrents/categories", {
+ method: "GET",
+ cache: "no-store"
+ })
+ .then(async (response) => {
+ if (!response.ok)
+ return;
+
+ const data = await response.json();
+
+ categories = data;
+ for (const i in data) {
+ if (!Object.hasOwn(data, i))
+ continue;
+
+ const category = data[i];
+ const option = document.createElement("option");
+ option.value = category.name;
+ option.textContent = category.name;
+ $("categorySelect").appendChild(option);
}
- }
- }).send();
+ });
};
const getPreferences = () => {
diff --git a/src/webui/www/private/scripts/prop-files.js b/src/webui/www/private/scripts/prop-files.js
index 9cbae8c7c568..6d05571bd096 100644
--- a/src/webui/www/private/scripts/prop-files.js
+++ b/src/webui/www/private/scripts/prop-files.js
@@ -308,18 +308,20 @@ window.qBittorrent.PropFiles ??= (() => {
clearTimeout(loadTorrentFilesDataTimer);
loadTorrentFilesDataTimer = -1;
- new Request({
- url: "api/v2/torrents/filePrio",
- method: "post",
- data: {
- "hash": current_hash,
- "id": fileIds.join("|"),
- "priority": priority
- },
- onComplete: () => {
+ fetch("api/v2/torrents/filePrio", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hash": current_hash,
+ "id": fileIds.join("|"),
+ "priority": priority
+ })
+ })
+ .then((response) => {
+ if (!response.ok)
+ return;
+
loadTorrentFilesDataTimer = loadTorrentFilesData.delay(1000);
- }
- }).send();
+ });
const ignore = (priority === FilePriority.Ignored);
ids.forEach((_id) => {
@@ -352,16 +354,16 @@ window.qBittorrent.PropFiles ??= (() => {
current_hash = new_hash;
loadedNewTorrent = true;
}
- const url = new URI("api/v2/torrents/files?hash=" + current_hash);
- new Request.JSON({
- url: url,
- method: "get",
- noCache: true,
- onComplete: () => {
- clearTimeout(loadTorrentFilesDataTimer);
- loadTorrentFilesDataTimer = loadTorrentFilesData.delay(5000);
- },
- onSuccess: (files) => {
+ fetch(new URI("api/v2/torrents/files").setData("hash", current_hash), {
+ method: "GET",
+ cache: "no-store"
+ })
+ .then(async (response) => {
+ if (!response.ok)
+ return;
+
+ const files = await response.json();
+
clearTimeout(torrentFilesFilterInputTimer);
torrentFilesFilterInputTimer = -1;
@@ -373,8 +375,11 @@ window.qBittorrent.PropFiles ??= (() => {
if (loadedNewTorrent)
collapseAllNodes();
}
- }
- }).send();
+ })
+ .finally(() => {
+ clearTimeout(loadTorrentFilesDataTimer);
+ loadTorrentFilesDataTimer = loadTorrentFilesData.delay(5000);
+ });
};
const updateData = () => {
diff --git a/src/webui/www/private/scripts/prop-general.js b/src/webui/www/private/scripts/prop-general.js
index 2fe7e32c44d9..698d6b508ee9 100644
--- a/src/webui/www/private/scripts/prop-general.js
+++ b/src/webui/www/private/scripts/prop-general.js
@@ -87,18 +87,22 @@ window.qBittorrent.PropGeneral ??= (() => {
clearTimeout(loadTorrentDataTimer);
return;
}
- const url = new URI("api/v2/torrents/properties?hash=" + current_id);
- new Request.JSON({
- url: url,
- method: "get",
- noCache: true,
- onFailure: () => {
- $("error_div").textContent = "QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]";
- clearTimeout(loadTorrentDataTimer);
- loadTorrentDataTimer = loadTorrentData.delay(10000);
- },
- onSuccess: (data) => {
+
+ fetch(new URI("api/v2/torrents/properties").setData("hash", current_id), {
+ method: "GET",
+ cache: "no-store"
+ })
+ .then(async (response) => {
+ if (!response.ok) {
+ $("error_div").textContent = "QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]";
+ clearTimeout(loadTorrentDataTimer);
+ loadTorrentDataTimer = loadTorrentData.delay(10000);
+ return;
+ }
+
$("error_div").textContent = "";
+
+ const data = await response.json();
if (data) {
// Update Torrent data
@@ -224,22 +228,23 @@ window.qBittorrent.PropGeneral ??= (() => {
}
clearTimeout(loadTorrentDataTimer);
loadTorrentDataTimer = loadTorrentData.delay(5000);
- }
- }).send();
-
- const piecesUrl = new URI("api/v2/torrents/pieceStates?hash=" + current_id);
- new Request.JSON({
- url: piecesUrl,
- method: "get",
- noCache: true,
- onFailure: () => {
- $("error_div").textContent = "QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]";
- clearTimeout(loadTorrentDataTimer);
- loadTorrentDataTimer = loadTorrentData.delay(10000);
- },
- onSuccess: (data) => {
+ });
+
+ fetch(new URI("api/v2/torrents/pieceStates").setData("hash", current_id), {
+ method: "GET",
+ cache: "no-store"
+ })
+ .then(async (response) => {
+ if (!response.ok) {
+ $("error_div").textContent = "QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]";
+ clearTimeout(loadTorrentDataTimer);
+ loadTorrentDataTimer = loadTorrentData.delay(10000);
+ return;
+ }
+
$("error_div").textContent = "";
+ const data = await response.json();
if (data)
piecesBar.setPieces(data);
else
@@ -247,8 +252,7 @@ window.qBittorrent.PropGeneral ??= (() => {
clearTimeout(loadTorrentDataTimer);
loadTorrentDataTimer = loadTorrentData.delay(5000);
- }
- }).send();
+ });
};
const updateData = () => {
diff --git a/src/webui/www/private/scripts/prop-peers.js b/src/webui/www/private/scripts/prop-peers.js
index bed2f4908bc6..d64ecd85f626 100644
--- a/src/webui/www/private/scripts/prop-peers.js
+++ b/src/webui/www/private/scripts/prop-peers.js
@@ -56,44 +56,45 @@ window.qBittorrent.PropPeers ??= (() => {
clearTimeout(loadTorrentPeersTimer);
return;
}
- const url = new URI("api/v2/sync/torrentPeers");
- url.setData("rid", syncTorrentPeersLastResponseId);
- url.setData("hash", current_hash);
- new Request.JSON({
- url: url,
- method: "get",
- noCache: true,
- onComplete: () => {
- clearTimeout(loadTorrentPeersTimer);
- loadTorrentPeersTimer = loadTorrentPeersData.delay(window.qBittorrent.Client.getSyncMainDataInterval());
- },
- onSuccess: (response) => {
+ const url = new URI("api/v2/sync/torrentPeers")
+ .setData("rid", syncTorrentPeersLastResponseId)
+ .setData("hash", current_hash);
+ fetch(url, {
+ method: "GET",
+ cache: "no-store"
+ })
+ .then(async (response) => {
+ if (!response.ok)
+ return;
+
+ const responseJSON = await response.json();
+
$("error_div").textContent = "";
- if (response) {
- const full_update = (response["full_update"] === true);
+ if (responseJSON) {
+ const full_update = (responseJSON["full_update"] === true);
if (full_update)
torrentPeersTable.clear();
- if (response["rid"])
- syncTorrentPeersLastResponseId = response["rid"];
- if (response["peers"]) {
- for (const key in response["peers"]) {
- if (!Object.hasOwn(response["peers"], key))
+ if (responseJSON["rid"])
+ syncTorrentPeersLastResponseId = responseJSON["rid"];
+ if (responseJSON["peers"]) {
+ for (const key in responseJSON["peers"]) {
+ if (!Object.hasOwn(responseJSON["peers"], key))
continue;
- response["peers"][key]["rowId"] = key;
- torrentPeersTable.updateRowData(response["peers"][key]);
+ responseJSON["peers"][key]["rowId"] = key;
+ torrentPeersTable.updateRowData(responseJSON["peers"][key]);
}
}
- if (response["peers_removed"]) {
- response["peers_removed"].each((hash) => {
+ if (responseJSON["peers_removed"]) {
+ responseJSON["peers_removed"].each((hash) => {
torrentPeersTable.removeRow(hash);
});
}
torrentPeersTable.updateTable(full_update);
- if (response["show_flags"]) {
- if (show_flags !== response["show_flags"]) {
- show_flags = response["show_flags"];
+ if (responseJSON["show_flags"]) {
+ if (show_flags !== responseJSON["show_flags"]) {
+ show_flags = responseJSON["show_flags"];
torrentPeersTable.columns["country"].force_hide = !show_flags;
torrentPeersTable.updateColumn("country");
}
@@ -102,8 +103,12 @@ window.qBittorrent.PropPeers ??= (() => {
else {
torrentPeersTable.clear();
}
- }
- }).send();
+
+ })
+ .finally(() => {
+ clearTimeout(loadTorrentPeersTimer);
+ loadTorrentPeersTimer = loadTorrentPeersData.delay(window.qBittorrent.Client.getSyncMainDataInterval());
+ });
};
const updateData = () => {
@@ -146,14 +151,13 @@ window.qBittorrent.PropPeers ??= (() => {
return;
if (confirm("QBT_TR(Are you sure you want to permanently ban the selected peers?)QBT_TR[CONTEXT=PeerListWidget]")) {
- new Request({
- url: "api/v2/transfer/banPeers",
- method: "post",
- data: {
- hash: torrentsTable.getCurrentTorrentID(),
- peers: selectedPeers.join("|")
- }
- }).send();
+ fetch("api/v2/transfer/banPeers", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hash": torrentsTable.getCurrentTorrentID(),
+ "peers": selectedPeers.join("|")
+ })
+ });
}
}
},
diff --git a/src/webui/www/private/scripts/speedslider.js b/src/webui/www/private/scripts/speedslider.js
index 49f636ef8ceb..250b70cb18fd 100644
--- a/src/webui/www/private/scripts/speedslider.js
+++ b/src/webui/www/private/scripts/speedslider.js
@@ -32,24 +32,28 @@ MochaUI.extend({
addUpLimitSlider: (hashes) => {
if ($("uplimitSliderarea")) {
// Get global upload limit
- let maximum = 500;
- new Request({
- url: "api/v2/transfer/uploadLimit",
- method: "get",
- data: {},
- onSuccess: (data) => {
- if (data) {
- const tmp = Number(data);
- if (tmp > 0) {
- maximum = tmp / 1024.0;
- }
- else {
- if (hashes[0] === "global")
- maximum = 10000;
- else
- maximum = 1000;
- }
+ fetch("api/v2/transfer/uploadLimit", {
+ method: "GET",
+ cache: "no-store"
+ })
+ .then(async (response) => {
+ if (!response.ok)
+ return;
+
+ const data = await response.text();
+
+ let maximum = 500;
+ const tmp = Number(data);
+ if (tmp > 0) {
+ maximum = tmp / 1024.0;
}
+ else {
+ if (hashes[0] === "global")
+ maximum = 10000;
+ else
+ maximum = 1000;
+ }
+
// Get torrents upload limit
// And create slider
if (hashes[0] === "global") {
@@ -83,77 +87,82 @@ MochaUI.extend({
}
}
else {
- new Request.JSON({
- url: "api/v2/torrents/uploadLimit",
- method: "post",
- data: {
- hashes: hashes.join("|")
- },
- onSuccess: (data) => {
- if (data) {
- let up_limit = data[hashes[0]];
- for (const key in data) {
- if (up_limit !== data[key]) {
- up_limit = 0;
- break;
- }
- }
- if (up_limit < 0)
+ fetch("api/v2/torrents/uploadLimit", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hashes": hashes.join("|")
+ })
+ })
+ .then(async (response) => {
+ if (!response.ok)
+ return;
+
+ const data = await response.json();
+
+ let up_limit = data[hashes[0]];
+ for (const key in data) {
+ if (up_limit !== data[key]) {
up_limit = 0;
- new Slider($("uplimitSliderarea"), $("uplimitSliderknob"), {
- steps: maximum,
- offset: 0,
- initialStep: (up_limit / 1024.0).round(),
- onChange: (pos) => {
- if (pos > 0) {
- $("uplimitUpdatevalue").value = pos;
- $("upLimitUnit").style.visibility = "visible";
- }
- else {
- $("uplimitUpdatevalue").value = "∞";
- $("upLimitUnit").style.visibility = "hidden";
- }
- }
- });
- // Set default value
- if (up_limit === 0) {
- $("uplimitUpdatevalue").value = "∞";
- $("upLimitUnit").style.visibility = "hidden";
+ break;
}
- else {
- $("uplimitUpdatevalue").value = (up_limit / 1024.0).round();
- $("upLimitUnit").style.visibility = "visible";
+ }
+ if (up_limit < 0)
+ up_limit = 0;
+ new Slider($("uplimitSliderarea"), $("uplimitSliderknob"), {
+ steps: maximum,
+ offset: 0,
+ initialStep: (up_limit / 1024.0).round(),
+ onChange: (pos) => {
+ if (pos > 0) {
+ $("uplimitUpdatevalue").value = pos;
+ $("upLimitUnit").style.visibility = "visible";
+ }
+ else {
+ $("uplimitUpdatevalue").value = "∞";
+ $("upLimitUnit").style.visibility = "hidden";
+ }
}
+ });
+ // Set default value
+ if (up_limit === 0) {
+ $("uplimitUpdatevalue").value = "∞";
+ $("upLimitUnit").style.visibility = "hidden";
}
- }
- }).send();
+ else {
+ $("uplimitUpdatevalue").value = (up_limit / 1024.0).round();
+ $("upLimitUnit").style.visibility = "visible";
+ }
+ });
}
- }
- }).send();
+ });
}
},
addDlLimitSlider: (hashes) => {
if ($("dllimitSliderarea")) {
// Get global upload limit
- let maximum = 500;
- new Request({
- url: "api/v2/transfer/downloadLimit",
- method: "get",
- data: {},
- onSuccess: (data) => {
- if (data) {
- const tmp = Number(data);
- if (tmp > 0) {
- maximum = tmp / 1024.0;
- }
- else {
- if (hashes[0] === "global")
- maximum = 10000;
- else
- maximum = 1000;
- }
+ fetch("api/v2/transfer/downloadLimit", {
+ method: "GET",
+ cache: "no-store"
+ })
+ .then(async (response) => {
+ if (!response.ok)
+ return;
+
+ const data = await response.text();
+
+ let maximum = 500;
+ const tmp = Number(data);
+ if (tmp > 0) {
+ maximum = tmp / 1024.0;
}
+ else {
+ if (hashes[0] === "global")
+ maximum = 10000;
+ else
+ maximum = 1000;
+ }
+
// Get torrents download limit
// And create slider
if (hashes[0] === "global") {
@@ -187,53 +196,54 @@ MochaUI.extend({
}
}
else {
- new Request.JSON({
- url: "api/v2/torrents/downloadLimit",
- method: "post",
- data: {
- hashes: hashes.join("|")
- },
- onSuccess: (data) => {
- if (data) {
- let dl_limit = data[hashes[0]];
- for (const key in data) {
- if (dl_limit !== data[key]) {
- dl_limit = 0;
- break;
- }
- }
- if (dl_limit < 0)
+ fetch("api/v2/torrents/downloadLimit", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hashes": hashes.join("|")
+ })
+ })
+ .then(async (response) => {
+ if (!response.ok)
+ return;
+
+ const data = await response.json();
+
+ let dl_limit = data[hashes[0]];
+ for (const key in data) {
+ if (dl_limit !== data[key]) {
dl_limit = 0;
- new Slider($("dllimitSliderarea"), $("dllimitSliderknob"), {
- steps: maximum,
- offset: 0,
- initialStep: (dl_limit / 1024.0).round(),
- onChange: (pos) => {
- if (pos > 0) {
- $("dllimitUpdatevalue").value = pos;
- $("dlLimitUnit").style.visibility = "visible";
- }
- else {
- $("dllimitUpdatevalue").value = "∞";
- $("dlLimitUnit").style.visibility = "hidden";
- }
- }
- });
- // Set default value
- if (dl_limit === 0) {
- $("dllimitUpdatevalue").value = "∞";
- $("dlLimitUnit").style.visibility = "hidden";
+ break;
}
- else {
- $("dllimitUpdatevalue").value = (dl_limit / 1024.0).round();
- $("dlLimitUnit").style.visibility = "visible";
+ }
+ if (dl_limit < 0)
+ dl_limit = 0;
+ new Slider($("dllimitSliderarea"), $("dllimitSliderknob"), {
+ steps: maximum,
+ offset: 0,
+ initialStep: (dl_limit / 1024.0).round(),
+ onChange: (pos) => {
+ if (pos > 0) {
+ $("dllimitUpdatevalue").value = pos;
+ $("dlLimitUnit").style.visibility = "visible";
+ }
+ else {
+ $("dllimitUpdatevalue").value = "∞";
+ $("dlLimitUnit").style.visibility = "hidden";
+ }
}
+ });
+ // Set default value
+ if (dl_limit === 0) {
+ $("dllimitUpdatevalue").value = "∞";
+ $("dlLimitUnit").style.visibility = "hidden";
}
- }
- }).send();
+ else {
+ $("dllimitUpdatevalue").value = (dl_limit / 1024.0).round();
+ $("dlLimitUnit").style.visibility = "visible";
+ }
+ });
}
- }
- }).send();
+ });
}
}
});
diff --git a/src/webui/www/private/setlocation.html b/src/webui/www/private/setlocation.html
index cecdb29d7b26..fee8d2f09804 100644
--- a/src/webui/www/private/setlocation.html
+++ b/src/webui/www/private/setlocation.html
@@ -45,21 +45,21 @@
return;
}
- const hashesList = new URI().getData("hashes");
- new Request({
- url: "api/v2/torrents/setLocation",
- method: "post",
- data: {
- hashes: hashesList,
- location: location
- },
- onSuccess: () => {
+ fetch("api/v2/torrents/setLocation", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hashes": new URI().getData("hashes"),
+ "location": location
+ })
+ })
+ .then(async (response) => {
+ if (!response.ok) {
+ $("error_div").textContent = await response.text();
+ return;
+ }
+
window.parent.qBittorrent.Client.closeFrameWindow(window);
- },
- onFailure: (xhr) => {
- $("error_div").textContent = xhr.response;
- }
- }).send();
+ });
});
});
diff --git a/src/webui/www/private/shareratio.html b/src/webui/www/private/shareratio.html
index 8c6f36fff612..418fbc3f1d81 100644
--- a/src/webui/www/private/shareratio.html
+++ b/src/webui/www/private/shareratio.html
@@ -100,19 +100,21 @@
return;
}
- new Request({
- url: "api/v2/torrents/setShareLimits",
- method: "post",
- data: {
- hashes: hashesList.join("|"),
- ratioLimit: ratioLimitValue,
- seedingTimeLimit: seedingTimeLimitValue,
- inactiveSeedingTimeLimit: inactiveSeedingTimeLimitValue
- },
- onComplete: () => {
+ fetch("api/v2/torrents/setShareLimits", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hashes": hashesList.join("|"),
+ "ratioLimit": ratioLimitValue,
+ "seedingTimeLimit": seedingTimeLimitValue,
+ "inactiveSeedingTimeLimit": inactiveSeedingTimeLimitValue
+ })
+ })
+ .then(async (response) => {
+ if (!response.ok)
+ return;
+
window.parent.qBittorrent.Client.closeFrameWindow(window);
- }
- }).send();
+ });
});
});
diff --git a/src/webui/www/private/uploadlimit.html b/src/webui/www/private/uploadlimit.html
index 8494eab31943..e0667a3c81c0 100644
--- a/src/webui/www/private/uploadlimit.html
+++ b/src/webui/www/private/uploadlimit.html
@@ -50,30 +50,34 @@
const setUpLimit = () => {
const limit = Number($("uplimitUpdatevalue").value) * 1024;
if (hashes[0] === "global") {
- new Request({
- url: "api/v2/transfer/setUploadLimit",
- method: "post",
- data: {
- "limit": limit
- },
- onComplete: () => {
+ fetch("api/v2/transfer/setUploadLimit", {
+ method: "POST",
+ body: new URLSearchParams({
+ "limit": limit
+ })
+ })
+ .then((response) => {
+ if (!response.ok)
+ return;
+
window.parent.updateMainData();
window.parent.qBittorrent.Client.closeFrameWindow(window);
- }
- }).send();
+ });
}
else {
- new Request({
- url: "api/v2/torrents/setUploadLimit",
- method: "post",
- data: {
- "hashes": hashes.join("|"),
- "limit": limit
- },
- onComplete: () => {
+ fetch("api/v2/torrents/setUploadLimit", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hashes": hashes.join("|"),
+ "limit": limit
+ })
+ })
+ .then((response) => {
+ if (!response.ok)
+ return;
+
window.parent.qBittorrent.Client.closeFrameWindow(window);
- }
- }).send();
+ });
}
};
diff --git a/src/webui/www/private/views/confirmAutoTMM.html b/src/webui/www/private/views/confirmAutoTMM.html
index 787a3d3b8bb4..3ec551e38e86 100644
--- a/src/webui/www/private/views/confirmAutoTMM.html
+++ b/src/webui/www/private/views/confirmAutoTMM.html
@@ -26,21 +26,22 @@
cancelButton.addEventListener("click", (e) => { window.qBittorrent.Client.closeWindow(windowEl); });
confirmButton.addEventListener("click", (e) => {
- new Request({
- url: "api/v2/torrents/setAutoManagement",
- method: "post",
- data: {
- hashes: hashes.join("|"),
- enable: enable
- },
- onSuccess: () => {
+ fetch("api/v2/torrents/setAutoManagement", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hashes": hashes.join("|"),
+ "enable": enable
+ })
+ })
+ .then((response) => {
+ if (!response.ok) {
+ alert("QBT_TR(Unable to set Auto Torrent Management for the selected torrents.)QBT_TR[CONTEXT=HttpServer]");
+ return;
+ }
+
updateMainData();
window.qBittorrent.Client.closeWindow(windowEl);
- },
- onFailure: () => {
- alert("QBT_TR(Unable to set Auto Torrent Management for the selected torrents.)QBT_TR[CONTEXT=HttpServer]");
- }
- }).send();
+ });
});
// set tabindex so window element receives keydown events
diff --git a/src/webui/www/private/views/confirmRecheck.html b/src/webui/www/private/views/confirmRecheck.html
index 09aa7041152e..baf69e647fb5 100644
--- a/src/webui/www/private/views/confirmRecheck.html
+++ b/src/webui/www/private/views/confirmRecheck.html
@@ -28,20 +28,21 @@
window.qBittorrent.Client.closeWindow(document.getElementById("confirmRecheckDialog"));
});
confirmButton.addEventListener("click", (e) => {
- new Request({
- url: "api/v2/torrents/recheck",
- method: "post",
- data: {
- hashes: hashes.join("|"),
- },
- onSuccess: () => {
+ fetch("api/v2/torrents/recheck", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hashes": hashes.join("|")
+ })
+ })
+ .then((response) => {
+ if (!response.ok) {
+ alert("QBT_TR(Unable to recheck torrents.)QBT_TR[CONTEXT=HttpServer]");
+ return;
+ }
+
updateMainData();
window.qBittorrent.Client.closeWindow(document.getElementById("confirmRecheckDialog"));
- },
- onFailure: () => {
- alert("QBT_TR(Unable to recheck torrents.)QBT_TR[CONTEXT=HttpServer]");
- }
- }).send();
+ });
});
// set tabindex so window element receives keydown events
diff --git a/src/webui/www/private/views/confirmdeletion.html b/src/webui/www/private/views/confirmdeletion.html
index feabbd9fb9fe..eafef6bfabed 100644
--- a/src/webui/www/private/views/confirmdeletion.html
+++ b/src/webui/www/private/views/confirmdeletion.html
@@ -77,23 +77,24 @@
? torrentsTable.getFilteredTorrentsHashes(selectedStatus, selectedCategory, selectedTag, selectedTracker)
: torrentsTable.selectedRowsIds();
- new Request({
- url: "api/v2/torrents/delete",
- method: "post",
- data: {
- "hashes": hashes.join("|"),
- "deleteFiles": deleteCB.checked
- },
- onSuccess: () => {
+ fetch("api/v2/torrents/delete", {
+ method: "POST",
+ body: new URLSearchParams({
+ "hashes": hashes.join("|"),
+ "deleteFiles": deleteCB.checked
+ })
+ })
+ .then((response) => {
+ if (!response.ok) {
+ alert("QBT_TR(Unable to delete torrents.)QBT_TR[CONTEXT=HttpServer]");
+ return;
+ }
+
torrentsTable.deselectAll();
updateMainData();
updatePropertiesPanel();
window.qBittorrent.Client.closeWindow(document.getElementById("confirmDeletionPage"));
- },
- onFailure: () => {
- alert("QBT_TR(Unable to delete torrents.)QBT_TR[CONTEXT=HttpServer]");
- },
- }).send();
+ });
});
})();
diff --git a/src/webui/www/private/views/log.html b/src/webui/www/private/views/log.html
index ace1399713ee..ca98f3dda390 100644
--- a/src/webui/www/private/views/log.html
+++ b/src/webui/www/private/views/log.html
@@ -356,48 +356,51 @@
url.setData("last_known_id", tableInfo[curTab].last_id);
tableInfo[curTab].progress = true;
- new Request.JSON({
- url: url,
- method: "get",
- noCache: true,
- onFailure: (response) => {
- const errorDiv = $("error_div");
- if (errorDiv)
- errorDiv.textContent = "QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]";
- tableInfo[curTab].progress = false;
- syncLogWithInterval(10000);
- },
- onSuccess: (response) => {
+ fetch(url, {
+ method: "GET",
+ cache: "no-store"
+ })
+ .then(async (response) => {
+ if (!response.ok) {
+ const errorDiv = $("error_div");
+ if (errorDiv)
+ errorDiv.textContent = "QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]";
+ tableInfo[curTab].progress = false;
+ syncLogWithInterval(10000);
+ return;
+ }
+
$("error_div").textContent = "";
if ($("logTabColumn").classList.contains("invisible"))
return;
- if (response.length > 0) {
+ const responseJSON = await response.json();
+ if (responseJSON.length > 0) {
clearTimeout(logFilterTimer);
logFilterTimer = -1;
- for (let i = 0; i < response.length; ++i) {
+ for (let i = 0; i < responseJSON.length; ++i) {
let row;
if (curTab === "main") {
row = {
- rowId: response[i].id,
- message: response[i].message,
- timestamp: response[i].timestamp,
- type: response[i].type,
+ rowId: responseJSON[i].id,
+ message: responseJSON[i].message,
+ timestamp: responseJSON[i].timestamp,
+ type: responseJSON[i].type,
};
}
else {
row = {
- rowId: response[i].id,
- ip: response[i].ip,
- timestamp: response[i].timestamp,
- blocked: response[i].blocked,
- reason: response[i].reason,
+ rowId: responseJSON[i].id,
+ ip: responseJSON[i].ip,
+ timestamp: responseJSON[i].timestamp,
+ blocked: responseJSON[i].blocked,
+ reason: responseJSON[i].reason,
};
}
tableInfo[curTab].instance.updateRowData(row);
- tableInfo[curTab].last_id = Math.max(Number(response[i].id), tableInfo[curTab].last_id);
+ tableInfo[curTab].last_id = Math.max(Number(responseJSON[i].id), tableInfo[curTab].last_id);
}
tableInfo[curTab].instance.updateTable();
@@ -406,8 +409,7 @@
tableInfo[curTab].progress = false;
syncLogWithInterval(getSyncLogDataInterval());
- }
- }).send();
+ });
};
new ClipboardJS(".copyLogDataToClipboard", {