WebUI: prefer range based for loop

Using `entries()` can also save the work of manually handling the index variable.

PR #23182.
This commit is contained in:
Chocobo1
2025-08-31 21:54:48 +08:00
committed by GitHub
parent b851caa6b9
commit dffd27a879
14 changed files with 61 additions and 82 deletions

View File

@@ -383,8 +383,7 @@ const initializeWindows = () => {
let torrentsHaveSameShareRatio = true;
// check if all selected torrents have same share ratio
for (let i = 0; i < hashes.length; ++i) {
const hash = hashes[i];
for (const hash of hashes) {
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}|${row.share_limit_action}`;
@@ -1160,10 +1159,8 @@ const initializeWindows = () => {
const names = [];
if (selectedRows.length > 0) {
const rows = torrentsTable.getFilteredAndSortedRows();
for (let i = 0; i < selectedRows.length; ++i) {
const hash = selectedRows[i];
for (const hash of selectedRows)
names.push(rows[hash].full_data.name);
}
}
return names.join("\n");
};
@@ -1198,10 +1195,8 @@ const initializeWindows = () => {
const magnets = [];
if (selectedRows.length > 0) {
const rows = torrentsTable.getFilteredAndSortedRows();
for (let i = 0; i < selectedRows.length; ++i) {
const hash = selectedRows[i];
for (const hash of selectedRows)
magnets.push(rows[hash].full_data.magnet_uri);
}
}
return magnets.join("\n");
};
@@ -1215,8 +1210,7 @@ const initializeWindows = () => {
const comments = [];
if (selectedRows.length > 0) {
const rows = torrentsTable.getFilteredAndSortedRows();
for (let i = 0; i < selectedRows.length; ++i) {
const hash = selectedRows[i];
for (const hash of selectedRows) {
const comment = rows[hash].full_data.comment;
if (comment && (comment !== ""))
comments.push(comment);