1
0
mirror of https://github.com/qbittorrent/qBittorrent.git synced 2025-03-12 04:35:47 -07:00

WebUI: use native API for accessing query string

PR .
This commit is contained in:
Chocobo1 2025-01-12 21:36:59 +08:00 committed by GitHub
parent 11991e62f5
commit c622d50814
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
28 changed files with 292 additions and 203 deletions

@ -22,8 +22,8 @@
}
});
const hash = new URI().getData("hash");
if (!hash)
const hash = new URLSearchParams(window.location.search).get("hash");
if (hash === null)
return;
$("peers").focus();

@ -30,7 +30,7 @@
fetch("api/v2/torrents/addTrackers", {
method: "POST",
body: new URLSearchParams({
hash: new URI().getData("hash"),
hash: new URLSearchParams(window.location.search).get("hash"),
urls: $("trackersUrls").value
})
})

@ -29,7 +29,7 @@
fetch("api/v2/torrents/addWebSeeds", {
method: "POST",
body: new URLSearchParams({
hash: new URI().getData("hash"),
hash: new URLSearchParams(window.location.search).get("hash"),
urls: $("urls").value.split("\n").map(w => encodeURIComponent(w.trim())).filter(w => (w.length > 0)).join("|")
})
})

@ -13,7 +13,6 @@
"use strict";
window.addEventListener("DOMContentLoaded", () => {
const paths = new URI().getData("paths").split("|");
$("cancelBtn").focus();
$("cancelBtn").addEventListener("click", (e) => {
e.preventDefault();
@ -25,7 +24,8 @@
e.stopPropagation();
let completionCount = 0;
paths.forEach((path) => {
const paths = new URLSearchParams(window.location.search).get("paths").split("|");
for (const path of paths) {
fetch("api/v2/rss/removeItem", {
method: "POST",
body: new URLSearchParams({
@ -42,7 +42,7 @@
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
});
});
}
});
});
</script>

@ -13,8 +13,6 @@
"use strict";
window.addEventListener("DOMContentLoaded", () => {
const rules = new URI().getData("rules").split("|");
$("cancelBtn").focus();
$("cancelBtn").addEventListener("click", (e) => {
e.preventDefault();
@ -26,7 +24,8 @@
e.stopPropagation();
let completionCount = 0;
rules.forEach((rule) => {
const rules = new URLSearchParams(window.location.search).get("rules").split("|");
for (const rule of rules) {
window.parent.qBittorrent.RssDownloader.modifyRuleState(decodeURIComponent(rule), "previouslyMatchedEpisodes", [], () => {
++completionCount;
if (completionCount === rules.length) {
@ -34,7 +33,7 @@
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
});
});
}
});
});
</script>

@ -13,8 +13,6 @@
"use strict";
window.addEventListener("DOMContentLoaded", () => {
const rules = new URI().getData("rules").split("|");
$("cancelBtn").focus();
$("cancelBtn").addEventListener("click", (e) => {
e.preventDefault();
@ -26,7 +24,8 @@
e.stopPropagation();
let completionCount = 0;
rules.forEach((rule) => {
const rules = new URLSearchParams(window.location.search).get("rules").split("|");
for (const rule of rules) {
fetch("api/v2/rss/removeRule", {
method: "POST",
body: new URLSearchParams({
@ -43,7 +42,7 @@
window.parent.qBittorrent.Client.closeFrameWindow(window);
}
});
});
}
});
});
</script>

@ -13,9 +13,10 @@
"use strict";
window.addEventListener("DOMContentLoaded", () => {
const host = new URI().getData("host");
const urls = new URI().getData("urls");
$("confirmDeleteTrackerText").textContent = "QBT_TR(Are you sure you want to remove tracker %1 from all torrents?)QBT_TR[CONTEXT=TrackersFilterWidget]".replace("%1", `"${host}"`);
const searchParams = new URLSearchParams(window.location.search);
const host = searchParams.get("host");
$("confirmDeleteTrackerText").textContent = "QBT_TR(Are you sure you want to remove tracker %1 from all torrents?)QBT_TR[CONTEXT=TrackersFilterWidget]".replace("%1", host);
$("cancelBtn").focus();
$("cancelBtn").addEventListener("click", (e) => {
@ -29,7 +30,7 @@
method: "POST",
body: new URLSearchParams({
hash: "*",
urls: urls
urls: searchParams.get("urls")
})
})
.then((response) => {

@ -163,13 +163,10 @@
<script>
"use strict";
const encodedUrls = new URI().getData("urls");
if (encodedUrls) {
const urls = encodedUrls.split("|").map((url) => {
return decodeURIComponent(url);
});
if (urls.length)
const encodedUrls = new URLSearchParams(window.location.search).get("urls");
if (encodedUrls !== null) {
const urls = encodedUrls.split("|").map(decodeURIComponent);
if (urls.length > 0)
$("urls").value = urls.join("\n");
}

@ -46,7 +46,7 @@
}
});
const hashes = new URI().getData("hashes").split("|");
const hashes = new URLSearchParams(window.location.search).get("hashes").split("|");
const setDlLimit = () => {
const limit = Number($("dllimitUpdatevalue").value) * 1024;
if (hashes[0] === "global") {

@ -27,7 +27,8 @@
}
});
const currentUrl = new URI().getData("url");
const searchParams = new URLSearchParams(window.location.search);
const currentUrl = searchParams.get("url");
$("url").value = currentUrl;
$("url").focus();
@ -54,7 +55,7 @@
fetch("api/v2/rss/setFeedURL", {
method: "POST",
body: new URLSearchParams({
path: new URI().getData("path"),
path: searchParams.get("path"),
url: newUrl
})
})

@ -26,8 +26,9 @@
}
});
const currentUrl = new URI().getData("url");
if (!currentUrl)
const searchParams = new URLSearchParams(window.location.search);
const currentUrl = searchParams.get("url");
if (currentUrl === null)
return;
$("trackerUrl").value = currentUrl;
@ -40,7 +41,7 @@
fetch("api/v2/torrents/editTracker", {
method: "POST",
body: new URLSearchParams({
hash: new URI().getData("hash"),
hash: searchParams.get("hash"),
origUrl: currentUrl,
newUrl: $("trackerUrl").value
})

@ -26,7 +26,8 @@
}
});
const origUrl = new URI().getData("url");
const searchParams = new URLSearchParams(window.location.search);
const origUrl = searchParams.get("url");
$("url").value = decodeURIComponent(origUrl);
$("url").focus();
@ -36,7 +37,7 @@
fetch("api/v2/torrents/editWebSeed", {
method: "POST",
body: new URLSearchParams({
hash: new URI().getData("hash"),
hash: searchParams.get("hash"),
origUrl: origUrl,
newUrl: encodeURIComponent($("url").value.trim())
})

@ -28,10 +28,11 @@
}
});
const uriAction = window.qBittorrent.Misc.safeTrim(new URI().getData("action"));
const uriHashes = window.qBittorrent.Misc.safeTrim(new URI().getData("hashes"));
const uriCategoryName = window.qBittorrent.Misc.safeTrim(new URI().getData("categoryName"));
const uriSavePath = window.qBittorrent.Misc.safeTrim(new URI().getData("savePath"));
const searchParams = new URLSearchParams(window.location.search);
const uriAction = window.qBittorrent.Misc.safeTrim(searchParams.get("action"));
const uriHashes = window.qBittorrent.Misc.safeTrim(searchParams.get("hashes"));
const uriCategoryName = window.qBittorrent.Misc.safeTrim(searchParams.get("categoryName"));
const uriSavePath = window.qBittorrent.Misc.safeTrim(searchParams.get("savePath"));
if (uriAction === "edit") {
if (!uriCategoryName)

@ -28,7 +28,6 @@
});
$("feedURL").focus();
const path = new URI().getData("path");
$("submitButton").addEventListener("click", (e) => {
e.preventDefault();
e.stopPropagation();
@ -42,11 +41,12 @@
$("submitButton").disabled = true;
const path = new URLSearchParams(window.location.search).get("path");
fetch("api/v2/rss/addFeed", {
method: "POST",
body: new URLSearchParams({
url: feedURL,
path: path ? (path + "\\" + feedURL) : ""
path: (((path !== null) && (path.length > 0)) ? `${path}\\${feedURL}` : "")
})
})
.then(async (response) => {

@ -29,7 +29,6 @@
});
$("folderName").focus();
const path = new URI().getData("path");
$("submitButton").addEventListener("click", (e) => {
e.preventDefault();
e.stopPropagation();
@ -43,10 +42,11 @@
$("submitButton").disabled = true;
const path = new URLSearchParams(window.location.search).get("path");
fetch("api/v2/rss/addFolder", {
method: "POST",
body: new URLSearchParams({
path: path ? (path + "\\" + folderName) : folderName
path: (((path !== null) && (path.length > 0)) ? `${path}\\${folderName}` : folderName)
})
})
.then(async (response) => {

@ -27,8 +27,8 @@
}
});
const uriAction = window.qBittorrent.Misc.safeTrim(new URI().getData("action"));
const uriHashes = window.qBittorrent.Misc.safeTrim(new URI().getData("hashes"));
const searchParams = new URLSearchParams(window.location.search);
const uriAction = window.qBittorrent.Misc.safeTrim(searchParams.get("action"));
if (uriAction === "create")
$("legendText").textContent = "QBT_TR(Tag:)QBT_TR[CONTEXT=TagFilterWidget]";
@ -52,8 +52,9 @@
};
switch (uriAction) {
case "set":
if (uriHashes === "")
case "set": {
const uriHashes = window.qBittorrent.Misc.safeTrim(searchParams.get("hashes"));
if ((uriHashes === null) || (uriHashes.length <= 0))
return;
fetch("api/v2/torrents/addTags", {
@ -70,6 +71,7 @@
window.parent.qBittorrent.Client.closeFrameWindow(window);
});
break;
}
case "create":
if (!verifyTagName(tagName))

@ -27,9 +27,10 @@
}
});
const name = new URI().getData("name");
const searchParams = new URLSearchParams(window.location.search);
const name = searchParams.get("name");
// set text field to current value
if (name)
if (name !== null)
$("rename").value = name;
$("rename").focus();
@ -42,8 +43,8 @@
if ((name === null) || (name === ""))
return;
const hash = new URI().getData("hash");
if (hash) {
const hash = searchParams.get("hash");
if (hash !== null) {
fetch("api/v2/torrents/rename", {
method: "POST",
body: new URLSearchParams({

@ -27,7 +27,7 @@
}
});
const oldPath = new URI().getData("oldPath");
const oldPath = new URLSearchParams(window.location.search).get("oldPath");
$("rename").value = oldPath;
$("rename").focus();

@ -28,9 +28,10 @@
}
});
const hash = new URI().getData("hash");
const oldPath = new URI().getData("path");
const isFolder = ((new URI().getData("isFolder")) === "true");
const searchParams = new URLSearchParams(window.location.search);
const hash = searchParams.get("hash");
const oldPath = searchParams.get("path");
const isFolder = ((searchParams.get("isFolder")) === "true");
const oldName = window.qBittorrent.Filesystem.fileName(oldPath);
$("rename").value = oldName;

@ -27,7 +27,7 @@
}
});
const oldName = new URI().getData("rule");
const oldName = new URLSearchParams(window.location.search).get("rule");
$("rename").value = oldName;
$("rename").focus();

@ -1656,7 +1656,7 @@ window.addEventListener("DOMContentLoaded", () => {
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Upload local torrent)QBT_TR[CONTEXT=HttpServer]",
loadMethod: "iframe",
contentURL: new URI("upload.html").toString(),
contentURL: "upload.html",
addClass: "windowFrame", // fixes iframe scrolling on iOS Safari
scrollbars: true,
maximizable: false,
@ -1693,13 +1693,16 @@ window.addEventListener("DOMContentLoaded", () => {
return;
const id = "downloadPage";
const contentURI = new URI("download.html").setData("urls", urls.map(encodeURIComponent).join("|"));
const contentURL = new URL("download.html", window.location);
contentURL.search = new URLSearchParams({
urls: urls.map(encodeURIComponent).join("|")
});
new MochaUI.Window({
id: id,
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Download from URLs)QBT_TR[CONTEXT=downloadFromURL]",
loadMethod: "iframe",
contentURL: contentURI.toString(),
contentURL: contentURL.toString(),
addClass: "windowFrame", // fixes iframe scrolling on iOS Safari
scrollbars: true,
maximizable: false,

@ -179,17 +179,20 @@ const initializeWindows = () => {
showDownloadPage = (urls) => {
const id = "downloadPage";
const contentUri = new URI("download.html");
const contentURL = new URL("download.html", window.location);
if (urls && (urls.length > 0))
contentUri.setData("urls", urls.map(encodeURIComponent).join("|"));
if (urls && (urls.length > 0)) {
contentURL.search = new URLSearchParams({
urls: urls.map(encodeURIComponent).join("|")
});
}
new MochaUI.Window({
id: id,
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Download from URLs)QBT_TR[CONTEXT=downloadFromURL]",
loadMethod: "iframe",
contentURL: contentUri.toString(),
contentURL: contentURL.toString(),
addClass: "windowFrame", // fixes iframe scrolling on iOS Safari
scrollbars: true,
maximizable: false,
@ -216,7 +219,7 @@ const initializeWindows = () => {
title: "QBT_TR(Options)QBT_TR[CONTEXT=OptionsDialog]",
loadMethod: "xhr",
toolbar: true,
contentURL: new URI("views/preferences.html").toString(),
contentURL: "views/preferences.html",
require: {
css: ["css/Tabs.css"]
},
@ -242,7 +245,7 @@ const initializeWindows = () => {
id: id,
title: "QBT_TR(Manage Cookies)QBT_TR[CONTEXT=CookiesDialog]",
loadMethod: "xhr",
contentURL: new URI("views/cookies.html").toString(),
contentURL: "views/cookies.html",
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
@ -264,7 +267,7 @@ const initializeWindows = () => {
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Upload local torrent)QBT_TR[CONTEXT=HttpServer]",
loadMethod: "iframe",
contentURL: new URI("upload.html").toString(),
contentURL: "upload.html",
addClass: "windowFrame", // fixes iframe scrolling on iOS Safari
scrollbars: true,
maximizable: false,
@ -280,12 +283,16 @@ const initializeWindows = () => {
});
globalUploadLimitFN = () => {
const contentURL = new URL("uploadlimit.html", window.location);
contentURL.search = new URLSearchParams({
hashes: "global"
});
new MochaUI.Window({
id: "uploadLimitPage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Global Upload Speed Limit)QBT_TR[CONTEXT=MainWindow]",
loadMethod: "iframe",
contentURL: new URI("uploadlimit.html").setData("hashes", "global").toString(),
contentURL: contentURL.toString(),
scrollbars: false,
resizable: false,
maximizable: false,
@ -298,63 +305,73 @@ const initializeWindows = () => {
uploadLimitFN = () => {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new MochaUI.Window({
id: "uploadLimitPage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Torrent Upload Speed Limiting)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe",
contentURL: new URI("uploadlimit.html").setData("hashes", hashes.join("|")).toString(),
scrollbars: false,
resizable: false,
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
width: 424,
height: 100
});
}
if (hashes.length <= 0)
return;
const contentURL = new URL("uploadlimit.html", window.location);
contentURL.search = new URLSearchParams({
hashes: hashes.join("|")
});
new MochaUI.Window({
id: "uploadLimitPage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Torrent Upload Speed Limiting)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe",
contentURL: contentURL.toString(),
scrollbars: false,
resizable: false,
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
width: 424,
height: 100
});
};
shareRatioFN = () => {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
let shareRatio = null;
let torrentsHaveSameShareRatio = true;
if (hashes.length <= 0)
return;
// check if all selected torrents have same share ratio
for (let i = 0; i < hashes.length; ++i) {
const hash = hashes[i];
const row = torrentsTable.getRow(hash).full_data;
const origValues = row.ratio_limit + "|" + row.seeding_time_limit + "|" + row.inactive_seeding_time_limit + "|"
+ row.max_ratio + "|" + row.max_seeding_time + "|" + row.max_inactive_seeding_time;
let shareRatio = null;
let torrentsHaveSameShareRatio = true;
// initialize value
if (shareRatio === null)
shareRatio = origValues;
// check if all selected torrents have same share ratio
for (let i = 0; i < hashes.length; ++i) {
const hash = hashes[i];
const row = torrentsTable.getRow(hash).full_data;
const origValues = row.ratio_limit + "|" + row.seeding_time_limit + "|" + row.inactive_seeding_time_limit + "|"
+ row.max_ratio + "|" + row.max_seeding_time + "|" + row.max_inactive_seeding_time;
if (origValues !== shareRatio) {
torrentsHaveSameShareRatio = false;
break;
}
// initialize value
if (shareRatio === null)
shareRatio = origValues;
if (origValues !== shareRatio) {
torrentsHaveSameShareRatio = false;
break;
}
// if all torrents have same share ratio, display that share ratio. else use the default
const orig = torrentsHaveSameShareRatio ? shareRatio : "";
new MochaUI.Window({
id: "shareRatioPage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Torrent Upload/Download Ratio Limiting)QBT_TR[CONTEXT=UpDownRatioDialog]",
loadMethod: "iframe",
contentURL: new URI("shareratio.html").setData("hashes", hashes.join("|")).setData("orig", orig).toString(),
scrollbars: false,
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
width: 424,
height: 220
});
}
const contentURL = new URL("shareratio.html", window.location);
contentURL.search = new URLSearchParams({
hashes: hashes.join("|"),
// if all torrents have same share ratio, display that share ratio. else use the default
orig: torrentsHaveSameShareRatio ? shareRatio : ""
});
new MochaUI.Window({
id: "shareRatioPage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Torrent Upload/Download Ratio Limiting)QBT_TR[CONTEXT=UpDownRatioDialog]",
loadMethod: "iframe",
contentURL: contentURL.toString(),
scrollbars: false,
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
width: 424,
height: 220
});
};
toggleSequentialDownloadFN = () => {
@ -412,12 +429,16 @@ const initializeWindows = () => {
};
globalDownloadLimitFN = () => {
const contentURL = new URL("downloadlimit.html", window.location);
contentURL.search = new URLSearchParams({
hashes: "global"
});
new MochaUI.Window({
id: "downloadLimitPage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Global Download Speed Limit)QBT_TR[CONTEXT=MainWindow]",
loadMethod: "iframe",
contentURL: new URI("downloadlimit.html").setData("hashes", "global").toString(),
contentURL: contentURL.toString(),
scrollbars: false,
resizable: false,
maximizable: false,
@ -435,7 +456,7 @@ const initializeWindows = () => {
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Statistics)QBT_TR[CONTEXT=StatsDialog]",
loadMethod: "xhr",
contentURL: new URI("views/statistics.html").toString(),
contentURL: "views/statistics.html",
maximizable: false,
padding: 10,
width: loadWindowWidth(id, 285),
@ -448,22 +469,27 @@ const initializeWindows = () => {
downloadLimitFN = () => {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
new MochaUI.Window({
id: "downloadLimitPage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Torrent Download Speed Limiting)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe",
contentURL: new URI("downloadlimit.html").setData("hashes", hashes.join("|")).toString(),
scrollbars: false,
resizable: false,
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
width: 424,
height: 100
});
}
if (hashes.length <= 0)
return;
const contentURL = new URL("downloadlimit.html", window.location);
contentURL.search = new URLSearchParams({
hashes: hashes.join("|")
});
new MochaUI.Window({
id: "downloadLimitPage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Torrent Download Speed Limiting)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe",
contentURL: contentURL.toString(),
scrollbars: false,
resizable: false,
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
width: 424,
height: 100
});
};
deleteSelectedTorrentsFN = (forceDeleteFiles = false) => {
@ -625,49 +651,58 @@ const initializeWindows = () => {
setLocationFN = () => {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
const hash = hashes[0];
const row = torrentsTable.getRow(hash);
if (hashes.length <= 0)
return;
new MochaUI.Window({
id: "setLocationPage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Set location)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe",
contentURL: new URI("setlocation.html").setData("hashes", hashes.join("|")).setData("path", encodeURIComponent(row.full_data.save_path)).toString(),
scrollbars: false,
resizable: true,
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
width: 400,
height: 130
});
}
const contentURL = new URL("setlocation.html", window.location);
contentURL.search = new URLSearchParams({
hashes: hashes.join("|"),
path: encodeURIComponent(torrentsTable.getRow(hashes[0]).full_data.save_path)
});
new MochaUI.Window({
id: "setLocationPage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Set location)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe",
contentURL: contentURL.toString(),
scrollbars: false,
resizable: true,
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
width: 400,
height: 130
});
};
renameFN = () => {
const hashes = torrentsTable.selectedRowsIds();
if (hashes.length === 1) {
const hash = hashes[0];
const row = torrentsTable.getRow(hash);
if (row) {
new MochaUI.Window({
id: "renamePage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Rename)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe",
contentURL: new URI("rename.html").setData("hash", hash).setData("name", row.full_data.name).toString(),
scrollbars: false,
resizable: true,
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
width: 400,
height: 100
});
}
}
if (hashes.length !== 1)
return;
const row = torrentsTable.getRow(hashes[0]);
if (!row)
return;
const contentURL = new URL("rename.html", window.location);
contentURL.search = new URLSearchParams({
hash: hashes[0],
name: row.full_data.name
});
new MochaUI.Window({
id: "renamePage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Rename)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe",
contentURL: contentURL.toString(),
scrollbars: false,
resizable: true,
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
width: 400,
height: 100
});
};
renameFilesFN = () => {
@ -784,12 +819,17 @@ const initializeWindows = () => {
if (hashes.length <= 0)
return;
const contentURL = new URL("newcategory.html", window.location);
contentURL.search = new URLSearchParams({
action: "set",
hashes: hashes.join("|")
});
new MochaUI.Window({
id: "newCategoryPage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(New Category)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe",
contentURL: new URI("newcategory.html").setData("action", "set").setData("hashes", hashes.join("|")).toString(),
contentURL: contentURL.toString(),
scrollbars: false,
resizable: true,
maximizable: false,
@ -821,12 +861,16 @@ const initializeWindows = () => {
};
createCategoryFN = () => {
const contentURL = new URL("newcategory.html", window.location);
contentURL.search = new URLSearchParams({
action: "create"
});
new MochaUI.Window({
id: "newCategoryPage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(New Category)QBT_TR[CONTEXT=CategoryFilterWidget]",
loadMethod: "iframe",
contentURL: new URI("newcategory.html").setData("action", "create").toString(),
contentURL: contentURL.toString(),
scrollbars: false,
resizable: true,
maximizable: false,
@ -838,12 +882,17 @@ const initializeWindows = () => {
};
createSubcategoryFN = (category) => {
const contentURL = new URL("newcategory.html", window.location);
contentURL.search = new URLSearchParams({
action: "createSubcategory",
categoryName: `${category}/`
});
new MochaUI.Window({
id: "newSubcategoryPage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(New Category)QBT_TR[CONTEXT=CategoryFilterWidget]",
loadMethod: "iframe",
contentURL: new URI("newcategory.html").setData("action", "createSubcategory").setData("categoryName", `${category}/`).toString(),
contentURL: contentURL.toString(),
scrollbars: false,
resizable: true,
maximizable: false,
@ -855,12 +904,18 @@ const initializeWindows = () => {
};
editCategoryFN = (category) => {
const contentURL = new URL("newcategory.html", window.location);
contentURL.search = new URLSearchParams({
action: "edit",
categoryName: category,
savePath: categoryMap.get(category).savePath
});
new MochaUI.Window({
id: "editCategoryPage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Edit Category)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe",
contentURL: new URI("newcategory.html").setData("action", "edit").setData("categoryName", category).setData("savePath", categoryMap.get(category).savePath).toString(),
contentURL: contentURL.toString(),
scrollbars: false,
resizable: true,
maximizable: false,
@ -913,12 +968,17 @@ const initializeWindows = () => {
if (hashes.length <= 0)
return;
const contentURL = new URL("newtag.html", window.location);
contentURL.search = new URLSearchParams({
action: "set",
hashes: hashes.join("|")
});
new MochaUI.Window({
id: "newTagPage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Add tags)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe",
contentURL: new URI("newtag.html").setData("action", "set").setData("hashes", hashes.join("|")).toString(),
contentURL: contentURL.toString(),
scrollbars: false,
resizable: true,
maximizable: false,
@ -956,12 +1016,16 @@ const initializeWindows = () => {
};
createTagFN = () => {
const contentURL = new URL("newtag.html", window.location);
contentURL.search = new URLSearchParams({
action: "create"
});
new MochaUI.Window({
id: "newTagPage",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(New Tag)QBT_TR[CONTEXT=TagFilterWidget]",
loadMethod: "iframe",
contentURL: new URI("newtag.html").setData("action", "create").toString(),
contentURL: contentURL.toString(),
scrollbars: false,
resizable: true,
maximizable: false,
@ -1002,12 +1066,16 @@ const initializeWindows = () => {
if ((trackerHost === TRACKERS_ALL) || (trackerHost === TRACKERS_TRACKERLESS))
return;
const trackerURLs = [...trackerMap.get(trackerHost).keys()].map(encodeURIComponent).join("|");
const contentURL = new URL("confirmtrackerdeletion.html", window.location);
contentURL.search = new URLSearchParams({
host: trackerHost,
urls: [...trackerMap.get(trackerHost).keys()].map(encodeURIComponent).join("|")
});
new MochaUI.Window({
id: "confirmDeletionPage",
title: "QBT_TR(Remove tracker)QBT_TR[CONTEXT=confirmDeletionDlg]",
loadMethod: "iframe",
contentURL: new URI("confirmtrackerdeletion.html").setData("host", trackerHost).setData("urls", trackerURLs).toString(),
contentURL: contentURL.toString(),
scrollbars: false,
resizable: true,
maximizable: false,
@ -1099,7 +1167,10 @@ const initializeWindows = () => {
continue;
const name = row.full_data.name;
const url = new URI("api/v2/torrents/export").setData("hash", hash).toString();
const url = new URL("api/v2/torrents/export", window.location);
url.search = new URLSearchParams({
hash: hash
});
// download response to file
await window.qBittorrent.Misc.downloadFile(url, `${name}.torrent`, "QBT_TR(Unable to export torrent file)QBT_TR[CONTEXT=MainWindow]");
@ -1190,7 +1261,7 @@ const initializeWindows = () => {
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(About qBittorrent)QBT_TR[CONTEXT=AboutDialog]",
loadMethod: "xhr",
contentURL: new URI("views/about.html").toString(),
contentURL: "views/about.html",
require: {
css: ["css/Tabs.css"]
},

@ -56,9 +56,11 @@ window.qBittorrent.PropPeers ??= (() => {
clearTimeout(loadTorrentPeersTimer);
return;
}
const url = new URI("api/v2/sync/torrentPeers")
.setData("rid", syncTorrentPeersLastResponseId)
.setData("hash", current_hash);
const url = new URL("api/v2/sync/torrentPeers", window.location);
url.search = new URLSearchParams({
hash: current_hash,
rid: syncTorrentPeersLastResponseId,
});
fetch(url, {
method: "GET",
cache: "no-store"

@ -27,10 +27,11 @@
}
});
const path = new URI().getData("path");
const searchParams = new URLSearchParams(window.location.search);
const path = searchParams.get("path");
// set text field to current value
if (path)
if (path !== null)
$("setLocation").value = decodeURIComponent(path);
$("setLocation").focus();
@ -48,7 +49,7 @@
fetch("api/v2/torrents/setLocation", {
method: "POST",
body: new URLSearchParams({
hashes: new URI().getData("hashes"),
hashes: searchParams.get("hashes"),
location: location
})
})

@ -30,8 +30,8 @@
}
});
const hashesList = new URI().getData("hashes").split("|");
const origValues = new URI().getData("orig").split("|");
const searchParams = new URLSearchParams(window.location.search);
const origValues = searchParams.get("orig").split("|");
const values = {
ratioLimit: window.qBittorrent.Misc.friendlyFloat(origValues[0], 2),
@ -103,7 +103,7 @@
fetch("api/v2/torrents/setShareLimits", {
method: "POST",
body: new URLSearchParams({
hashes: hashesList.join("|"),
hashes: searchParams.get("hashes"),
ratioLimit: ratioLimitValue,
seedingTimeLimit: seedingTimeLimitValue,
inactiveSeedingTimeLimit: inactiveSeedingTimeLimitValue

@ -46,7 +46,7 @@
}
});
const hashes = new URI().getData("hashes").split("|");
const hashes = new URLSearchParams(window.location.search).get("hashes").split("|");
const setUpLimit = () => {
const limit = Number($("uplimitUpdatevalue").value) * 1024;
if (hashes[0] === "global") {

@ -340,20 +340,23 @@
curTab = currentSelectedTab;
let url;
if (curTab === "main") {
url = new URI("api/v2/log/main");
url.setData({
normal: selectedLogLevels.includes("1"),
info: selectedLogLevels.includes("2"),
warning: selectedLogLevels.includes("4"),
critical: selectedLogLevels.includes("8")
});
}
else {
url = new URI("api/v2/log/peers");
switch (curTab) {
case "main":
url = new URL("api/v2/log/main", window.location);
url.search = new URLSearchParams({
normal: selectedLogLevels.includes("1"),
info: selectedLogLevels.includes("2"),
warning: selectedLogLevels.includes("4"),
critical: selectedLogLevels.includes("8")
});
break;
case "peer":
url = new URL("api/v2/log/peers", window.location);
break;
}
url.setData("last_known_id", tableInfo[curTab].last_id);
url.searchParams.set("last_known_id", tableInfo[curTab].last_id);
tableInfo[curTab].progress = true;
fetch(url, {

@ -743,12 +743,17 @@
};
const editUrl = (path, url) => {
const contentURL = new URL("editfeedurl.html", window.location);
contentURL.search = new URLSearchParams({
path: path,
url: url
});
new MochaUI.Window({
id: "editFeedURL",
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Please type a RSS feed URL)QBT_TR[CONTEXT=RSSWidget]",
loadMethod: "iframe",
contentURL: new URI("editfeedurl.html").setData("path", path).setData("url", url).toString(),
contentURL: contentURL.toString(),
scrollbars: false,
resizable: false,
maximizable: false,