@@ -17,68 +17,68 @@ function find(selector, elem) { // eslint-disable-line no-redeclare
1717 return elem . querySelector ( selector ) ;
1818}
1919
20- function find_all ( selector , elem ) {
20+ function findAll ( selector , elem ) {
2121 if ( ! elem ) {
2222 elem = document ;
2323 }
2424 return toArray ( elem . querySelectorAll ( selector ) ) ;
2525}
2626
27- function sort_column ( elem ) {
28- toggle_sort_states ( elem ) ;
27+ function sortColumn ( elem ) {
28+ toggleSortStates ( elem ) ;
2929 const colIndex = toArray ( elem . parentNode . childNodes ) . indexOf ( elem ) ;
3030 let key ;
3131 if ( elem . classList . contains ( 'result' ) ) {
32- key = key_result ;
32+ key = keyResult ;
3333 } else if ( elem . classList . contains ( 'links' ) ) {
34- key = key_link ;
34+ key = keyLink ;
3535 } else {
36- key = key_alpha ;
36+ key = keyAlpha ;
3737 }
38- sort_table ( elem , key ( colIndex ) ) ;
38+ sortTable ( elem , key ( colIndex ) ) ;
3939}
4040
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 ) ;
4343}
4444
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 ) ;
4747}
4848
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 ;
5252 extras . classList . remove ( 'collapsed' ) ;
5353 expandcollapse . classList . remove ( 'expander' ) ;
5454 expandcollapse . classList . add ( 'collapser' ) ;
5555}
5656
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 ;
6060 extras . classList . add ( 'collapsed' ) ;
6161 expandcollapse . classList . remove ( 'collapser' ) ;
6262 expandcollapse . classList . add ( 'expander' ) ;
6363}
6464
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 ;
6969}
7070
71- function add_collapse ( ) {
71+ function addCollapse ( ) {
7272 // Add links for show/hide all
7373 const resulttable = find ( 'table#results-table' ) ;
7474 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>' ;
7777 resulttable . parentElement . insertBefore ( showhideall , resulttable ) ;
7878
7979 // 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' ;
8282 const extras = elem . parentNode . nextElementSibling ;
8383 const expandcollapse = document . createElement ( 'span' ) ;
8484 if ( extras . classList . contains ( 'collapsed' ) ) {
@@ -93,40 +93,40 @@ function add_collapse() {
9393
9494 elem . addEventListener ( 'click' , function ( event ) {
9595 if ( event . currentTarget . parentNode . nextElementSibling . classList . contains ( 'collapsed' ) ) {
96- show_extras ( event . currentTarget ) ;
96+ showExtras ( event . currentTarget ) ;
9797 } else {
98- hide_extras ( event . currentTarget ) ;
98+ hideExtras ( event . currentTarget ) ;
9999 }
100100 } ) ;
101101 } ) ;
102102}
103103
104- function get_query_parameter ( name ) {
104+ function getQueryParameter ( name ) {
105105 const match = RegExp ( '[?&]' + name + '=([^&]*)' ) . exec ( window . location . search ) ;
106106 return match && decodeURIComponent ( match [ 1 ] . replace ( / \+ / g, ' ' ) ) ;
107107}
108108
109109function init ( ) { // eslint-disable-line no-unused-vars
110- reset_sort_headers ( ) ;
110+ resetSortHeaders ( ) ;
111111
112- add_collapse ( ) ;
112+ addCollapse ( ) ;
113113
114- show_filters ( ) ;
114+ showFilters ( ) ;
115115
116- sort_column ( find ( '.initial-sort' ) ) ;
116+ sortColumn ( find ( '.initial-sort' ) ) ;
117117
118- find_all ( '.sortable' ) . forEach ( function ( elem ) {
118+ findAll ( '.sortable' ) . forEach ( function ( elem ) {
119119 elem . addEventListener ( 'click' ,
120120 function ( ) {
121- sort_column ( elem ) ;
121+ sortColumn ( elem ) ;
122122 } , false ) ;
123123 } ) ;
124124}
125125
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' ) ;
128128 const reversed = ! clicked . classList . contains ( 'asc' ) ;
129- const sorted_rows = sort ( rows , key_func , reversed ) ;
129+ const sortedRows = sort ( rows , keyFunc , reversed ) ;
130130 /* Whole table is removed here because browsers acts much slower
131131 * when appending existing elements.
132132 */
@@ -135,62 +135,62 @@ function sort_table(clicked, key_func) {
135135 const parent = document . createElement ( 'table' ) ;
136136 parent . id = 'results-table' ;
137137 parent . appendChild ( thead ) ;
138- sorted_rows . forEach ( function ( elem ) {
138+ sortedRows . forEach ( function ( elem ) {
139139 parent . appendChild ( elem ) ;
140140 } ) ;
141141 document . getElementsByTagName ( 'BODY' ) [ 0 ] . appendChild ( parent ) ;
142142}
143143
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 ] ;
147147 } ) ;
148148
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 ] ;
152152
153- if ( key_a == key_b ) return 0 ;
153+ if ( keyA == keyB ) return 0 ;
154154
155155 if ( reversed ) {
156- return key_a < key_b ? 1 : - 1 ;
156+ return keyA < keyB ? 1 : - 1 ;
157157 } else {
158- return key_a > key_b ? 1 : - 1 ;
158+ return keyA > keyB ? 1 : - 1 ;
159159 }
160160 } ) ;
161161
162- return sort_array . map ( function ( item ) {
162+ return sortArray . map ( function ( item ) {
163163 const index = item [ 1 ] ;
164164 return items [ index ] ;
165165 } ) ;
166166}
167167
168- function key_alpha ( col_index ) {
168+ function keyAlpha ( colIndex ) {
169169 return function ( elem ) {
170- return elem . childNodes [ 1 ] . childNodes [ col_index ] . firstChild . data . toLowerCase ( ) ;
170+ return elem . childNodes [ 1 ] . childNodes [ colIndex ] . firstChild . data . toLowerCase ( ) ;
171171 } ;
172172}
173173
174- function key_link ( col_index ) {
174+ function keyLink ( colIndex ) {
175175 return function ( elem ) {
176- const dataCell = elem . childNodes [ 1 ] . childNodes [ col_index ] . firstChild ;
176+ const dataCell = elem . childNodes [ 1 ] . childNodes [ colIndex ] . firstChild ;
177177 return dataCell == null ? '' : dataCell . innerText . toLowerCase ( ) ;
178178 } ;
179179}
180180
181- function key_result ( col_index ) {
181+ function keyResult ( colIndex ) {
182182 return function ( elem ) {
183183 const strings = [ 'Error' , 'Failed' , 'Rerun' , 'XFailed' , 'XPassed' ,
184184 '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 ) ;
186186 } ;
187187}
188188
189- function reset_sort_headers ( ) {
190- find_all ( '.sort-icon' ) . forEach ( function ( elem ) {
189+ function resetSortHeaders ( ) {
190+ findAll ( '.sort-icon' ) . forEach ( function ( elem ) {
191191 elem . parentNode . removeChild ( elem ) ;
192192 } ) ;
193- find_all ( '.sortable' ) . forEach ( function ( elem ) {
193+ findAll ( '.sortable' ) . forEach ( function ( elem ) {
194194 const icon = document . createElement ( 'div' ) ;
195195 icon . className = 'sort-icon' ;
196196 icon . textContent = 'vvv' ;
@@ -200,7 +200,7 @@ function reset_sort_headers() {
200200 } ) ;
201201}
202202
203- function toggle_sort_states ( elem ) {
203+ function toggleSortStates ( elem ) {
204204 //if active, toggle between asc and desc
205205 if ( elem . classList . contains ( 'active' ) ) {
206206 elem . classList . toggle ( 'asc' ) ;
@@ -209,28 +209,28 @@ function toggle_sort_states(elem) {
209209
210210 //if inactive, reset all other functions and add ascending active
211211 if ( elem . classList . contains ( 'inactive' ) ) {
212- reset_sort_headers ( ) ;
212+ resetSortHeaders ( ) ;
213213 elem . classList . remove ( 'inactive' ) ;
214214 elem . classList . add ( 'active' ) ;
215215 }
216216}
217217
218- function is_all_rows_hidden ( value ) {
218+ function isAllRowsHidden ( value ) {
219219 return value . hidden == false ;
220220}
221221
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 ) ;
227227
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 ;
230230 }
231231
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 ;
236236}
0 commit comments