@@ -17,68 +17,68 @@ function find(selector, elem) { // eslint-disable-line no-redeclare
17
17
return elem . querySelector ( selector ) ;
18
18
}
19
19
20
- function find_all ( selector , elem ) {
20
+ function findAll ( selector , elem ) {
21
21
if ( ! elem ) {
22
22
elem = document ;
23
23
}
24
24
return toArray ( elem . querySelectorAll ( selector ) ) ;
25
25
}
26
26
27
- function sort_column ( elem ) {
28
- toggle_sort_states ( elem ) ;
27
+ function sortColumn ( elem ) {
28
+ toggleSortStates ( elem ) ;
29
29
const colIndex = toArray ( elem . parentNode . childNodes ) . indexOf ( elem ) ;
30
30
let key ;
31
31
if ( elem . classList . contains ( 'result' ) ) {
32
- key = key_result ;
32
+ key = keyResult ;
33
33
} else if ( elem . classList . contains ( 'links' ) ) {
34
- key = key_link ;
34
+ key = keyLink ;
35
35
} else {
36
- key = key_alpha ;
36
+ key = keyAlpha ;
37
37
}
38
- sort_table ( elem , key ( colIndex ) ) ;
38
+ sortTable ( elem , key ( colIndex ) ) ;
39
39
}
40
40
41
- function show_all_extras ( ) { // eslint-disable-line no-unused-vars
42
- find_all ( '.col-result' ) . forEach ( show_extras ) ;
41
+ function showAllExtras ( ) { // eslint-disable-line no-unused-vars
42
+ findAll ( '.col-result' ) . forEach ( showExtras ) ;
43
43
}
44
44
45
- function hide_all_extras ( ) { // eslint-disable-line no-unused-vars
46
- find_all ( '.col-result' ) . forEach ( hide_extras ) ;
45
+ function hideAllExtras ( ) { // eslint-disable-line no-unused-vars
46
+ findAll ( '.col-result' ) . forEach ( hideExtras ) ;
47
47
}
48
48
49
- function show_extras ( colresult_elem ) {
50
- const extras = colresult_elem . parentNode . nextElementSibling ;
51
- const expandcollapse = colresult_elem . firstElementChild ;
49
+ function showExtras ( colresultElem ) {
50
+ const extras = colresultElem . parentNode . nextElementSibling ;
51
+ const expandcollapse = colresultElem . firstElementChild ;
52
52
extras . classList . remove ( 'collapsed' ) ;
53
53
expandcollapse . classList . remove ( 'expander' ) ;
54
54
expandcollapse . classList . add ( 'collapser' ) ;
55
55
}
56
56
57
- function hide_extras ( colresult_elem ) {
58
- const extras = colresult_elem . parentNode . nextElementSibling ;
59
- const expandcollapse = colresult_elem . firstElementChild ;
57
+ function hideExtras ( colresultElem ) {
58
+ const extras = colresultElem . parentNode . nextElementSibling ;
59
+ const expandcollapse = colresultElem . firstElementChild ;
60
60
extras . classList . add ( 'collapsed' ) ;
61
61
expandcollapse . classList . remove ( 'collapser' ) ;
62
62
expandcollapse . classList . add ( 'expander' ) ;
63
63
}
64
64
65
- function show_filters ( ) {
66
- const filter_items = document . getElementsByClassName ( 'filter' ) ;
67
- for ( let i = 0 ; i < filter_items . length ; i ++ )
68
- filter_items [ i ] . hidden = false ;
65
+ function showFilters ( ) {
66
+ const filterItems = document . getElementsByClassName ( 'filter' ) ;
67
+ for ( let i = 0 ; i < filterItems . length ; i ++ )
68
+ filterItems [ i ] . hidden = false ;
69
69
}
70
70
71
- function add_collapse ( ) {
71
+ function addCollapse ( ) {
72
72
// Add links for show/hide all
73
73
const resulttable = find ( 'table#results-table' ) ;
74
74
const showhideall = document . createElement ( 'p' ) ;
75
- showhideall . innerHTML = '<a href="javascript:show_all_extras ()">Show all details</a> / ' +
76
- '<a href="javascript:hide_all_extras ()">Hide all details</a>' ;
75
+ showhideall . innerHTML = '<a href="javascript:showAllExtras ()">Show all details</a> / ' +
76
+ '<a href="javascript:hideAllExtras ()">Hide all details</a>' ;
77
77
resulttable . parentElement . insertBefore ( showhideall , resulttable ) ;
78
78
79
79
// Add show/hide link to each result
80
- find_all ( '.col-result' ) . forEach ( function ( elem ) {
81
- const collapsed = get_query_parameter ( 'collapsed' ) || 'Passed' ;
80
+ findAll ( '.col-result' ) . forEach ( function ( elem ) {
81
+ const collapsed = getQueryParameter ( 'collapsed' ) || 'Passed' ;
82
82
const extras = elem . parentNode . nextElementSibling ;
83
83
const expandcollapse = document . createElement ( 'span' ) ;
84
84
if ( extras . classList . contains ( 'collapsed' ) ) {
@@ -93,40 +93,40 @@ function add_collapse() {
93
93
94
94
elem . addEventListener ( 'click' , function ( event ) {
95
95
if ( event . currentTarget . parentNode . nextElementSibling . classList . contains ( 'collapsed' ) ) {
96
- show_extras ( event . currentTarget ) ;
96
+ showExtras ( event . currentTarget ) ;
97
97
} else {
98
- hide_extras ( event . currentTarget ) ;
98
+ hideExtras ( event . currentTarget ) ;
99
99
}
100
100
} ) ;
101
101
} ) ;
102
102
}
103
103
104
- function get_query_parameter ( name ) {
104
+ function getQueryParameter ( name ) {
105
105
const match = RegExp ( '[?&]' + name + '=([^&]*)' ) . exec ( window . location . search ) ;
106
106
return match && decodeURIComponent ( match [ 1 ] . replace ( / \+ / g, ' ' ) ) ;
107
107
}
108
108
109
109
function init ( ) { // eslint-disable-line no-unused-vars
110
- reset_sort_headers ( ) ;
110
+ resetSortHeaders ( ) ;
111
111
112
- add_collapse ( ) ;
112
+ addCollapse ( ) ;
113
113
114
- show_filters ( ) ;
114
+ showFilters ( ) ;
115
115
116
- sort_column ( find ( '.initial-sort' ) ) ;
116
+ sortColumn ( find ( '.initial-sort' ) ) ;
117
117
118
- find_all ( '.sortable' ) . forEach ( function ( elem ) {
118
+ findAll ( '.sortable' ) . forEach ( function ( elem ) {
119
119
elem . addEventListener ( 'click' ,
120
120
function ( ) {
121
- sort_column ( elem ) ;
121
+ sortColumn ( elem ) ;
122
122
} , false ) ;
123
123
} ) ;
124
124
}
125
125
126
- function sort_table ( clicked , key_func ) {
127
- const rows = find_all ( '.results-table-row' ) ;
126
+ function sortTable ( clicked , keyFunc ) {
127
+ const rows = findAll ( '.results-table-row' ) ;
128
128
const reversed = ! clicked . classList . contains ( 'asc' ) ;
129
- const sorted_rows = sort ( rows , key_func , reversed ) ;
129
+ const sortedRows = sort ( rows , keyFunc , reversed ) ;
130
130
/* Whole table is removed here because browsers acts much slower
131
131
* when appending existing elements.
132
132
*/
@@ -135,62 +135,62 @@ function sort_table(clicked, key_func) {
135
135
const parent = document . createElement ( 'table' ) ;
136
136
parent . id = 'results-table' ;
137
137
parent . appendChild ( thead ) ;
138
- sorted_rows . forEach ( function ( elem ) {
138
+ sortedRows . forEach ( function ( elem ) {
139
139
parent . appendChild ( elem ) ;
140
140
} ) ;
141
141
document . getElementsByTagName ( 'BODY' ) [ 0 ] . appendChild ( parent ) ;
142
142
}
143
143
144
- function sort ( items , key_func , reversed ) {
145
- const sort_array = items . map ( function ( item , i ) {
146
- return [ key_func ( item ) , i ] ;
144
+ function sort ( items , keyFunc , reversed ) {
145
+ const sortArray = items . map ( function ( item , i ) {
146
+ return [ keyFunc ( item ) , i ] ;
147
147
} ) ;
148
148
149
- sort_array . sort ( function ( a , b ) {
150
- const key_a = a [ 0 ] ;
151
- const key_b = b [ 0 ] ;
149
+ sortArray . sort ( function ( a , b ) {
150
+ const keyA = a [ 0 ] ;
151
+ const keyB = b [ 0 ] ;
152
152
153
- if ( key_a == key_b ) return 0 ;
153
+ if ( keyA == keyB ) return 0 ;
154
154
155
155
if ( reversed ) {
156
- return key_a < key_b ? 1 : - 1 ;
156
+ return keyA < keyB ? 1 : - 1 ;
157
157
} else {
158
- return key_a > key_b ? 1 : - 1 ;
158
+ return keyA > keyB ? 1 : - 1 ;
159
159
}
160
160
} ) ;
161
161
162
- return sort_array . map ( function ( item ) {
162
+ return sortArray . map ( function ( item ) {
163
163
const index = item [ 1 ] ;
164
164
return items [ index ] ;
165
165
} ) ;
166
166
}
167
167
168
- function key_alpha ( col_index ) {
168
+ function keyAlpha ( colIndex ) {
169
169
return function ( elem ) {
170
- return elem . childNodes [ 1 ] . childNodes [ col_index ] . firstChild . data . toLowerCase ( ) ;
170
+ return elem . childNodes [ 1 ] . childNodes [ colIndex ] . firstChild . data . toLowerCase ( ) ;
171
171
} ;
172
172
}
173
173
174
- function key_link ( col_index ) {
174
+ function keyLink ( colIndex ) {
175
175
return function ( elem ) {
176
- const dataCell = elem . childNodes [ 1 ] . childNodes [ col_index ] . firstChild ;
176
+ const dataCell = elem . childNodes [ 1 ] . childNodes [ colIndex ] . firstChild ;
177
177
return dataCell == null ? '' : dataCell . innerText . toLowerCase ( ) ;
178
178
} ;
179
179
}
180
180
181
- function key_result ( col_index ) {
181
+ function keyResult ( colIndex ) {
182
182
return function ( elem ) {
183
183
const strings = [ 'Error' , 'Failed' , 'Rerun' , 'XFailed' , 'XPassed' ,
184
184
'Skipped' , 'Passed' ] ;
185
- return strings . indexOf ( elem . childNodes [ 1 ] . childNodes [ col_index ] . firstChild . data ) ;
185
+ return strings . indexOf ( elem . childNodes [ 1 ] . childNodes [ colIndex ] . firstChild . data ) ;
186
186
} ;
187
187
}
188
188
189
- function reset_sort_headers ( ) {
190
- find_all ( '.sort-icon' ) . forEach ( function ( elem ) {
189
+ function resetSortHeaders ( ) {
190
+ findAll ( '.sort-icon' ) . forEach ( function ( elem ) {
191
191
elem . parentNode . removeChild ( elem ) ;
192
192
} ) ;
193
- find_all ( '.sortable' ) . forEach ( function ( elem ) {
193
+ findAll ( '.sortable' ) . forEach ( function ( elem ) {
194
194
const icon = document . createElement ( 'div' ) ;
195
195
icon . className = 'sort-icon' ;
196
196
icon . textContent = 'vvv' ;
@@ -200,7 +200,7 @@ function reset_sort_headers() {
200
200
} ) ;
201
201
}
202
202
203
- function toggle_sort_states ( elem ) {
203
+ function toggleSortStates ( elem ) {
204
204
//if active, toggle between asc and desc
205
205
if ( elem . classList . contains ( 'active' ) ) {
206
206
elem . classList . toggle ( 'asc' ) ;
@@ -209,28 +209,28 @@ function toggle_sort_states(elem) {
209
209
210
210
//if inactive, reset all other functions and add ascending active
211
211
if ( elem . classList . contains ( 'inactive' ) ) {
212
- reset_sort_headers ( ) ;
212
+ resetSortHeaders ( ) ;
213
213
elem . classList . remove ( 'inactive' ) ;
214
214
elem . classList . add ( 'active' ) ;
215
215
}
216
216
}
217
217
218
- function is_all_rows_hidden ( value ) {
218
+ function isAllRowsHidden ( value ) {
219
219
return value . hidden == false ;
220
220
}
221
221
222
- function filter_table ( elem ) { // eslint-disable-line no-unused-vars
223
- const outcome_att = 'data-test-result' ;
224
- const outcome = elem . getAttribute ( outcome_att ) ;
225
- const class_outcome = outcome + ' results-table-row' ;
226
- const outcome_rows = document . getElementsByClassName ( class_outcome ) ;
222
+ function filterTable ( elem ) { // eslint-disable-line no-unused-vars
223
+ const outcomeAtt = 'data-test-result' ;
224
+ const outcome = elem . getAttribute ( outcomeAtt ) ;
225
+ const classOutcome = outcome + ' results-table-row' ;
226
+ const outcomeRows = document . getElementsByClassName ( classOutcome ) ;
227
227
228
- for ( let i = 0 ; i < outcome_rows . length ; i ++ ) {
229
- outcome_rows [ i ] . hidden = ! elem . checked ;
228
+ for ( let i = 0 ; i < outcomeRows . length ; i ++ ) {
229
+ outcomeRows [ i ] . hidden = ! elem . checked ;
230
230
}
231
231
232
- const rows = find_all ( '.results-table-row' ) . filter ( is_all_rows_hidden ) ;
233
- const all_rows_hidden = rows . length == 0 ? true : false ;
234
- const not_found_message = document . getElementById ( 'not-found-message' ) ;
235
- not_found_message . hidden = ! all_rows_hidden ;
232
+ const rows = findAll ( '.results-table-row' ) . filter ( isAllRowsHidden ) ;
233
+ const allRowsHidden = rows . length == 0 ? true : false ;
234
+ const notFoundMessage = document . getElementById ( 'not-found-message' ) ;
235
+ notFoundMessage . hidden = ! allRowsHidden ;
236
236
}
0 commit comments