mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-09 17:12:31 -06:00
WebUI: prefer for loop over Array.forEach method
The `for` loop can do everything `forEach` can and doesn't need a closure.
This commit is contained in:
@@ -210,9 +210,8 @@
|
||||
menu: "logTableMenu",
|
||||
actions: {
|
||||
Clear: () => {
|
||||
tableInfo[currentSelectedTab].instance.selectedRowsIds().forEach((rowId) => {
|
||||
for (const rowId of tableInfo[currentSelectedTab].instance.selectedRowsIds())
|
||||
tableInfo[currentSelectedTab].instance.removeRow(rowId);
|
||||
});
|
||||
|
||||
updateLabelCount();
|
||||
}
|
||||
|
||||
@@ -2144,7 +2144,8 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
||||
|
||||
// Advanced Tab
|
||||
const updateNetworkInterfaces = (default_iface, default_iface_name) => {
|
||||
[...document.getElementById("networkInterface").children].forEach((el) => { el.remove(); });
|
||||
for (const el of [...document.getElementById("networkInterface").children])
|
||||
el.remove();
|
||||
|
||||
fetch("api/v2/app/networkInterfaceList", {
|
||||
method: "GET",
|
||||
@@ -2165,15 +2166,15 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
||||
ifaces.push({ name: default_iface_name || default_iface, value: default_iface });
|
||||
|
||||
document.getElementById("networkInterface").options.add(new Option("QBT_TR(Any interface)QBT_TR[CONTEXT=OptionsDialog]", ""));
|
||||
ifaces.forEach((item, index) => {
|
||||
for (const item of ifaces)
|
||||
document.getElementById("networkInterface").options.add(new Option(item.name, item.value));
|
||||
});
|
||||
document.getElementById("networkInterface").value = default_iface;
|
||||
});
|
||||
};
|
||||
|
||||
const updateInterfaceAddresses = (iface, default_addr) => {
|
||||
[...document.getElementById("optionalIPAddressToBind").children].forEach((el) => { el.remove(); });
|
||||
for (const el of [...document.getElementById("optionalIPAddressToBind").children])
|
||||
el.remove();
|
||||
|
||||
const url = new URL("api/v2/app/networkInterfaceAddressList", window.location);
|
||||
url.search = new URLSearchParams({
|
||||
@@ -2196,9 +2197,8 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
||||
document.getElementById("optionalIPAddressToBind").options.add(new Option("QBT_TR(All addresses)QBT_TR[CONTEXT=OptionDialog]", ""));
|
||||
document.getElementById("optionalIPAddressToBind").options.add(new Option("QBT_TR(All IPv4 addresses)QBT_TR[CONTEXT=OptionDialog]", "0.0.0.0"));
|
||||
document.getElementById("optionalIPAddressToBind").options.add(new Option("QBT_TR(All IPv6 addresses)QBT_TR[CONTEXT=OptionDialog]", "::"));
|
||||
addresses.forEach((item, index) => {
|
||||
for (const item of addresses)
|
||||
document.getElementById("optionalIPAddressToBind").options.add(new Option(item, item));
|
||||
});
|
||||
document.getElementById("optionalIPAddressToBind").value = default_addr;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -233,7 +233,8 @@
|
||||
feedsToUpdate.add(row);
|
||||
}
|
||||
}
|
||||
feedsToUpdate.forEach((feed) => refreshFeed(feed.full_data.dataUid));
|
||||
for (const feed of feedsToUpdate)
|
||||
refreshFeed(feed.full_data.dataUid);
|
||||
},
|
||||
markRead: markSelectedAsRead,
|
||||
rename: (el) => {
|
||||
@@ -424,7 +425,8 @@
|
||||
};
|
||||
|
||||
const clearDetails = () => {
|
||||
[...document.getElementById("rssDetailsView").children].forEach((el) => { el.remove(); });
|
||||
for (const el of [...document.getElementById("rssDetailsView").children])
|
||||
el.remove();
|
||||
};
|
||||
|
||||
const showDetails = (feedUid, articleID) => {
|
||||
|
||||
@@ -789,14 +789,14 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
||||
|
||||
rssDownloaderFeedSelectionTable.clear();
|
||||
let rowID = -1;
|
||||
feedList.forEach((feed) => {
|
||||
for (const feed of feedList) {
|
||||
rssDownloaderFeedSelectionTable.updateRowData({
|
||||
rowId: ++rowID,
|
||||
checked: rulesList[ruleName].affectedFeeds.contains(feed.url),
|
||||
name: feed.name,
|
||||
url: feed.url
|
||||
});
|
||||
});
|
||||
}
|
||||
rssDownloaderFeedSelectionTable.updateTable(false);
|
||||
updateMatchingArticles(ruleName);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
if (!confirm("QBT_TR(Are you sure you want to delete selected tasks?)QBT_TR[CONTEXT=TorrentCreator]"))
|
||||
return;
|
||||
|
||||
selectedTasks.forEach(task => {
|
||||
for (const task of selectedTasks) {
|
||||
fetch("api/v2/torrentcreator/deleteTask", {
|
||||
method: "POST",
|
||||
body: new URLSearchParams({
|
||||
@@ -100,7 +100,7 @@
|
||||
}).then((response) => {
|
||||
load();
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
exportTorrent: exportTorrents,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user