@@ -63,9 +63,12 @@ document.addEventListener("DOMContentLoaded", function() {
6363 input . addEventListener ( "change" , function ( e ) {
6464 widget . filters [ idx ] = e . target . value ;
6565 removeAllChildNodes ( tbody ) ;
66+ elements = [ ] ;
6667 rows . filter ( isFilterMatch ) . map ( r => {
6768 tbody . appendChild ( r . el )
69+ elements . push ( r )
6870 } ) ;
71+ console . log ( elements ) ;
6972 } ) ;
7073 input . setAttribute ( 'style' , 'width:100%;display:block' )
7174 input . setAttribute ( 'type' , 'text' ) ;
@@ -104,6 +107,7 @@ document.addEventListener("DOMContentLoaded", function() {
104107 columns, // Needed for filtered
105108 } ;
106109 } ) ;
110+ let elements = rows ;
107111
108112 function addSortButton ( el , idx ) {
109113 const img = document . createElement ( 'img' ) ;
@@ -118,30 +122,31 @@ document.addEventListener("DOMContentLoaded", function() {
118122
119123 let direction = false ;
120124 function sortTable ( columnIndex ) {
125+ console . log ( elements ) ;
121126 removeAllChildNodes ( tbody ) ;
122- if ( isNaN ( rows [ 0 ] . columns [ columnIndex ] [ 0 ] ) && isNaN ( rows [ rows . length - 1 ] . columns [ columnIndex ] [ 0 ] ) ) {
123- rows . sort ( ( a , b ) => {
127+ if ( isNaN ( elements [ 0 ] . columns [ columnIndex ] [ 0 ] ) && isNaN ( elements [ elements . length - 1 ] . columns [ columnIndex ] [ 0 ] ) ) {
128+ elements . sort ( ( a , b ) => {
124129 a = a . columns [ columnIndex ] ;
125130 b = b . columns [ columnIndex ] ;
126131 return direction ? a . localeCompare ( b ) : b . localeCompare ( a ) ;
127132 } ) ;
128133 } else {
129134 if ( ! columnIndex && window . location . href . includes ( "docs/alerts" ) ) {
130- rows . sort ( ( a , b ) => {
135+ elements . sort ( ( a , b ) => {
131136 a = a . columns [ columnIndex ] . split ( "-" ) ;
132137 b = b . columns [ columnIndex ] . split ( "-" ) ;
133138 return direction ? a [ 0 ] - b [ 0 ] : b [ 0 ] - a [ 0 ] ;
134139 } ) ;
135140 } else {
136- rows . sort ( ( a , b ) => {
141+ elements . sort ( ( a , b ) => {
137142 a = a . columns [ columnIndex ] ;
138143 b = b . columns [ columnIndex ] ;
139144 return direction ? a - b : b - a ;
140145 } ) ;
141146 }
142147 }
143- for ( let i = 0 ; i <= rows . length - 1 ; i ++ ) {
144- tbody . appendChild ( rows [ i ] . el ) ;
148+ for ( let i = 0 ; i <= elements . length - 1 ; i ++ ) {
149+ tbody . appendChild ( elements [ i ] . el ) ;
145150 }
146151 direction = ! direction ;
147152 }
0 commit comments