File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed
Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -101,16 +101,28 @@ document$.subscribe(() => {
101101
102102 const prepRows = isDescending ? rows : rows . reverse ( ) ;
103103 const colorClasses = [ 'winner-gold' , 'winner-silver' , 'winner-bronze' ] ;
104+
104105 let currentId = 0 ;
105106 let topId = 0 ;
106- top_rows_length = prepRows . length < 3 ? prepRows . length : 3
107- while ( topId < top_rows_length ) {
108- $ ( dt . row ( prepRows [ currentId ] ) . node ( ) ) . addClass ( colorClasses [ topId ] ) ;
109- if ( getRank ( prepRows [ currentId ] ) != getRank ( prepRows [ currentId + 1 ] ) ) {
107+ const maxTopGroups = Math . min ( prepRows . length , colorClasses . length ) ;
108+
109+ while ( currentId < prepRows . length && topId < maxTopGroups ) {
110+ const rowIdx = prepRows [ currentId ] ;
111+ $ ( dt . row ( rowIdx ) . node ( ) ) . addClass ( colorClasses [ topId ] ) ;
112+
113+ const nextRowIdx = prepRows [ currentId + 1 ] ;
114+
115+ if ( nextRowIdx == null ) {
116+ break ;
117+ }
118+
119+ if ( getRank ( rowIdx ) !== getRank ( nextRowIdx ) ) {
110120 topId += 1 ;
111121 }
122+
112123 currentId += 1 ;
113- }
124+ }
125+
114126 } ;
115127
116128 paintWinners ( ) ;
You can’t perform that action at this time.
0 commit comments