projects
/
web
/
firmware-selector-openwrt-org.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d07da20
)
www/index.js: avoid use of c style for loop
author
Moritz Warning
<moritzwarning@web.de>
Tue, 15 Sep 2020 01:17:30 +0000
(
03:17
+0200)
committer
Moritz Warning
<moritzwarning@web.de>
Mon, 21 Sep 2020 14:02:39 +0000
(16:02 +0200)
www/index.js
patch
|
blob
|
history
diff --git
a/www/index.js
b/www/index.js
index 9f7c40b4d14f8713e4e178889dce09bb3e9ab582..b057cd219ba5c1b037c4458ee647e82c85d3e1ac 100644
(file)
--- a/
www/index.js
+++ b/
www/index.js
@@
-124,9
+124,9
@@
function build_asu_request() {
}
function setupSelectList(select, items, onselection) {
}
function setupSelectList(select, items, onselection) {
- for (
let i = 0; i < items.length; i += 1
) {
+ for (
const item of items
) {
const option = document.createElement("OPTION");
const option = document.createElement("OPTION");
- option.innerHTML = item
s[i]
;
+ option.innerHTML = item;
select.appendChild(option);
}
select.appendChild(option);
}
@@
-194,9
+194,7
@@
function setupAutocompleteList(input, items, as_list, onbegin, onend) {
const match = normalize(value);
let c = 0;
const match = normalize(value);
let c = 0;
- for (let i = 0; i < items.length; i += 1) {
- const item = items[i];
-
+ for (const item of items) {
// match
let j = normalize(item).indexOf(match);
if (j < 0) {
// match
let j = normalize(item).indexOf(match);
if (j < 0) {
@@
-277,26
+275,26
@@
function setupAutocompleteList(input, items, as_list, onbegin, onend) {
onend(input);
};
onend(input);
};
- function setActive(x) {
+ function setActive(x
s
) {
// a function to classify an item as 'active':
// a function to classify an item as 'active':
- if (!x) return false;
+ if (!x
s
) return false;
// start by removing the 'active' class on all items:
// start by removing the 'active' class on all items:
- for (
let i = 0; i < x.length; i++
) {
- x
[i]
.classList.remove("autocomplete-active");
+ for (
const x of xs
) {
+ x.classList.remove("autocomplete-active");
}
}
- if (currentFocus >= x.length) currentFocus = 0;
- if (currentFocus < 0) currentFocus = x.length - 1;
+ if (currentFocus >= x
s
.length) currentFocus = 0;
+ if (currentFocus < 0) currentFocus = x
s
.length - 1;
// add class 'autocomplete-active':
// add class 'autocomplete-active':
- x[currentFocus].classList.add("autocomplete-active");
+ x
s
[currentFocus].classList.add("autocomplete-active");
}
function closeAllLists(elmnt) {
// close all autocomplete lists in the document,
// except the one passed as an argument:
}
function closeAllLists(elmnt) {
// close all autocomplete lists in the document,
// except the one passed as an argument:
- const x = document.getElementsByClassName("autocomplete-items");
- for (
let i = 0; i < x.length; i++
) {
- if (elmnt != x
[i]
&& elmnt != input) {
- x
[i].parentNode.removeChild(x[i]
);
+ const x
s
= document.getElementsByClassName("autocomplete-items");
+ for (
const x of xs
) {
+ if (elmnt != x && elmnt != input) {
+ x
.parentNode.removeChild(x
);
}
}
}
}
}
}