Modernize for;;-loops
Change-Id: Ic6f86af0d674cc6643fc9eef2aa7431cfdf514f2
diff --git a/dev/js/src/menu.js b/dev/js/src/menu.js
index 98204ea..4d80419 100644
--- a/dev/js/src/menu.js
+++ b/dev/js/src/menu.js
@@ -206,7 +206,7 @@
if (this.prefix().length <= 0) {
// add all items to the list and lowlight
- var i = 0;
+ let i = 0;
for (; i < this._items.length; i++) {
this._list.push(i);
this._items[i].lowlight();
@@ -228,25 +228,22 @@
// Iterate over all items and choose preferred matching items
// i.e. the matching happens at the word start
- for (pos = 0; pos < this._items.length; pos++) {
+ this._items.forEach(function(it, pos){
- var points = 0;
+ let points = 0;
- for (pref = 0; pref < prefixList.length; pref++) {
- var prefix = " " + prefixList[pref];
+ prefixList.forEach(function(p) {
// Check if it matches at the beginning
- // if ((this.item(pos).lcField().indexOf(prefix)) >= 0) {
- if ((this.item(pos).lcField().includes(prefix))) {
+ if ((it.lcField().includes(" " + p))) {
points += 5;
}
// Check if it matches anywhere
- // else if ((this.item(pos).lcField().indexOf(prefix.substring(1))) >= 0) {
- else if ((this.item(pos).lcField().includes(prefix.substring(1)))) {
+ else if (it.lcField().includes(p)) {
points += 1;
};
- };
+ });
if (points > maxPoints) {
this._list = [pos];
@@ -255,7 +252,7 @@
else if (points == maxPoints) {
this._list.push(pos);
}
- };
+ },this);
// The list is empty - so lower your expectations
// Iterate over all items and choose matching items