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

@@ -387,27 +387,27 @@
clearTimeout(logFilterTimer);
logFilterTimer = -1;
for (let i = 0; i < responseJSON.length; ++i) {
for (const logEntry of responseJSON) {
let row;
if (curTab === "main") {
row = {
rowId: responseJSON[i].id,
message: responseJSON[i].message,
timestamp: responseJSON[i].timestamp,
type: responseJSON[i].type,
rowId: logEntry.id,
message: logEntry.message,
timestamp: logEntry.timestamp,
type: logEntry.type,
};
}
else {
row = {
rowId: responseJSON[i].id,
ip: responseJSON[i].ip,
timestamp: responseJSON[i].timestamp,
blocked: responseJSON[i].blocked,
reason: responseJSON[i].reason,
rowId: logEntry.id,
ip: logEntry.ip,
timestamp: logEntry.timestamp,
blocked: logEntry.blocked,
reason: logEntry.reason,
};
}
tableInfo[curTab].instance.updateRowData(row);
tableInfo[curTab].last_id = Math.max(Number(responseJSON[i].id), tableInfo[curTab].last_id);
tableInfo[curTab].last_id = Math.max(Number(logEntry.id), tableInfo[curTab].last_id);
}
tableInfo[curTab].instance.updateTable();