Skip to content

Commit 962464b

Browse files
Erwin DondorpErwin Dondorp
authored andcommitted
fixed codebeat reported 'block-scoped-var'
1 parent 57de2a9 commit 962464b

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

saltgui/static/sorttable/sorttable.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class SortTable {
3434

3535
// work through each column and calculate its type
3636
const headrow = table.tHead.rows[0].cells;
37-
for (var i=0; i<headrow.length; i++) {
37+
for (let i=0; i<headrow.length; i++) {
3838
// manually override the type with a sorttable_type attribute
3939
if (!headrow[i].classList.contains("sorttable_nosort")) { // skip this col
4040
const mtch = headrow[i].className.match(/\bsorttable_([a-z0-9]+)\b/);
@@ -92,7 +92,7 @@ export class SortTable {
9292
const row_array = [];
9393
const col = clickElement.sorttable_columnindex;
9494
const rows = clickElement.sorttable_tbody.rows;
95-
for (var j=0; j<rows.length; j++) {
95+
for (let j=0; j<rows.length; j++) {
9696
row_array[row_array.length] = [SortTable.getInnerText(rows[j].cells[col]), rows[j]];
9797
}
9898
/* If you want a stable sort, uncomment the following line */
@@ -102,7 +102,7 @@ export class SortTable {
102102
if(reverse) row_array.reverse();
103103

104104
const tb = clickElement.sorttable_tbody;
105-
for (var j=0; j<row_array.length; j++) {
105+
for (let j=0; j<row_array.length; j++) {
106106
tb.appendChild(row_array[j][1]);
107107
}
108108
}
@@ -142,7 +142,7 @@ export class SortTable {
142142
case 1:
143143
case 11:
144144
var innerText = '';
145-
for (var i = 0; i < node.childNodes.length; i++) {
145+
for (let i = 0; i < node.childNodes.length; i++) {
146146
innerText += SortTable.getInnerText(node.childNodes[i]);
147147
}
148148
return innerText.replace(/^\s+|\s+$/g, '');
@@ -155,10 +155,10 @@ export class SortTable {
155155
static reverse (tbody) {
156156
// reverse the rows in a tbody
157157
const newrows = [];
158-
for (var i=0; i<tbody.rows.length; i++) {
158+
for (let i=0; i<tbody.rows.length; i++) {
159159
newrows[newrows.length] = tbody.rows[i];
160160
}
161-
for (var i=newrows.length-1; i>=0; i--) {
161+
for (let i=newrows.length-1; i>=0; i--) {
162162
tbody.appendChild(newrows[i]);
163163
}
164164
}
@@ -182,19 +182,19 @@ export class SortTable {
182182

183183
while(swap) {
184184
swap = false;
185-
for(var i = b; i < t; ++i) {
185+
for(let i = b; i < t; ++i) {
186186
if ( comp_func(list[i], list[i+1]) > 0 ) {
187-
var q = list[i]; list[i] = list[i+1]; list[i+1] = q;
187+
const q = list[i]; list[i] = list[i+1]; list[i+1] = q;
188188
swap = true;
189189
}
190190
} // for
191191
t--;
192192

193193
if (!swap) break;
194194

195-
for(var i = t; i > b; --i) {
195+
for(let i = t; i > b; --i) {
196196
if ( comp_func(list[i], list[i-1]) < 0 ) {
197-
var q = list[i]; list[i] = list[i-1]; list[i-1] = q;
197+
const q = list[i]; list[i] = list[i-1]; list[i-1] = q;
198198
swap = true;
199199
}
200200
} // for

0 commit comments

Comments
 (0)