diff --git a/scripts/js/gravity.js b/scripts/js/gravity.js index f1438a8b..893763e8 100644 --- a/scripts/js/gravity.js +++ b/scripts/js/gravity.js @@ -76,16 +76,16 @@ function parseLines(ta, str) { // Splitting the text on "\r" const lines = str.split(/(?=\r)/g); - for (let i = 0; i < lines.length; i++) { - if (lines[i][0] === "\r") { + for (let line of lines) { + if (line[0] === "\r") { // This line starts with the "OVER" sequence. Replace them with "\n" before print - lines[i] = lines[i].replaceAll("\r[K", "\n").replaceAll("\r", "\n"); + line = line.replaceAll("\r[K", "\n").replaceAll("\r", "\n"); // Last line from the textarea will be overwritten, so we remove it ta.text(ta.text().substring(0, ta.text().lastIndexOf("\n"))); } // Append the new text to the end of the output - ta.append(lines[i]); + ta.append(line); } } diff --git a/scripts/js/groups-clients.js b/scripts/js/groups-clients.js index 1b3ef1ab..5d4e970c 100644 --- a/scripts/js/groups-clients.js +++ b/scripts/js/groups-clients.js @@ -29,8 +29,7 @@ function reloadClientSuggestions() { sel.append($("")); // Add data obtained from API - for (let i = 0; i < data.clients.length; i++) { - const client = data.clients[i]; + for (const client of data.clients) { let mockDevice = false; let text = client.hwaddr.toUpperCase(); let key = text; @@ -370,15 +369,11 @@ function addClient() { // - IPv6 address (with and without CIDR) // - MAC address (in the form AA:BB:CC:DD:EE:FF) // - host name (arbitrary form, we're only checking against some reserved characters) - for (let i = 0; i < ips.length; i++) { - if ( - utils.validateIPv4CIDR(ips[i]) || - utils.validateIPv6CIDR(ips[i]) || - utils.validateMAC(ips[i]) - ) { + for (const [index, ip] of ips.entries()) { + if (utils.validateIPv4CIDR(ip) || utils.validateIPv6CIDR(ip) || utils.validateMAC(ip)) { // Convert input to upper case (important for MAC addresses) - ips[i] = ips[i].toUpperCase(); - } else if (!utils.validateHostname(ips[i])) { + ips[index] = ip.toUpperCase(); + } else if (!utils.validateHostname(ip)) { utils.showAlert( "warning", "", diff --git a/scripts/js/groups-domains.js b/scripts/js/groups-domains.js index 679b63e3..ae7c56a7 100644 --- a/scripts/js/groups-domains.js +++ b/scripts/js/groups-domains.js @@ -503,12 +503,12 @@ function addDomain() { // Check if the wildcard checkbox was marked and transform the domains into regex if (kind === "exact" && wildcardChecked) { - for (let i = 0; i < domains.length; i++) { + for (const [index, domain] of domains.entries()) { // Strip leading "*." if specified by user in wildcard mode - if (domains[i].startsWith("*.")) domains[i] = domains[i].substr(2); + if (domain.startsWith("*.")) domains[index] = domain.substr(2); // Transform domain into a wildcard regex - domains[i] = "(\\.|^)" + domains[i].replaceAll(".", "\\.") + "$"; + domains[index] = "(\\.|^)" + domains[index].replaceAll(".", "\\.") + "$"; } kind = "regex"; diff --git a/scripts/js/network.js b/scripts/js/network.js index ec548d0e..3db36c37 100644 --- a/scripts/js/network.js +++ b/scripts/js/network.js @@ -96,7 +96,6 @@ $(() => { tableApi = $("#network-entries").DataTable({ rowCallback(row, data) { let color; - let index; let iconClasses; const lastQuery = Number.parseInt(data.lastQuery, 10); const diff = getTimestamp() - lastQuery; @@ -153,19 +152,18 @@ $(() => { return a.ip.localeCompare(b.ip); }); - for (index = 0; index < data.ips.length; index++) { - const ip = data.ips[index]; - let iptext = ip.ip; + for (const { ip, name } of data.ips) { + let iptext = ip; - if (ip.name !== null && ip.name.length > 0) { - iptext = iptext + " (" + ip.name + ")"; + if (name !== null && name.length > 0) { + iptext = `${iptext} (${name})`; } iptitles.push(iptext); // Only add IPs to the table if we have not reached the maximum - if (index < MAXIPDISPLAY) { - ips.push('' + iptext + ""); + if (ips.length < MAXIPDISPLAY) { + ips.push(`${iptext}`); } } diff --git a/scripts/js/settings-teleporter.js b/scripts/js/settings-teleporter.js index 560f11d2..623e5858 100644 --- a/scripts/js/settings-teleporter.js +++ b/scripts/js/settings-teleporter.js @@ -59,8 +59,8 @@ function importZIP() { $("#modal-import-success").show(); $("#modal-import-success-title").text("Import successful"); let text = "
Processed files: