ÿþ( f u n c t i o n ( $ ) { $ . e x t e n d ( { t a b l e s o r t e r : n e w   f u n c t i o n ( ) { v a r   p a r s e r s = [ ] , w i d g e t s = [ ] ; t h i s . d e f a u l t s = { c s s H e a d e r : " h e a d e r " , c s s A s c : " h e a d e r S o r t U p " , c s s D e s c : " h e a d e r S o r t D o w n " , s o r t I n i t i a l O r d e r : " a s c " , s o r t M u l t i S o r t K e y : " s h i f t K e y " , s o r t F o r c e : n u l l , s o r t A p p e n d : n u l l , t e x t E x t r a c t i o n : " s i m p l e " , p a r s e r s : { } , w i d g e t s : [ ] , w i d g e t Z e b r a : { c s s : [ " e v e n " , " o d d " ] } , h e a d e r s : { } , w i d t h F i x e d : f a l s e , c a n c e l S e l e c t i o n : t r u e , s o r t L i s t : [ ] , h e a d e r L i s t : [ ] , d a t e F o r m a t : " u s " , d e c i m a l : ' . ' , d e b u g : f a l s e } ; f u n c t i o n   b e n c h m a r k ( s , d ) { l o g ( s + " , " + ( n e w   D a t e ( ) . g e t T i m e ( ) - d . g e t T i m e ( ) ) + " m s " ) ; } t h i s . b e n c h m a r k = b e n c h m a r k ; f u n c t i o n   l o g ( s ) { i f ( t y p e o f   c o n s o l e ! = " u n d e f i n e d " & & t y p e o f   c o n s o l e . d e b u g ! = " u n d e f i n e d " ) { c o n s o l e . l o g ( s ) ; } e l s e { a l e r t ( s ) ; } } f u n c t i o n   b u i l d P a r s e r C a c h e ( t a b l e , $ h e a d e r s ) { i f ( t a b l e . c o n f i g . d e b u g ) { v a r   p a r s e r s D e b u g = " " ; } v a r   r o w s = t a b l e . t B o d i e s [ 0 ] . r o w s ; i f ( t a b l e . t B o d i e s [ 0 ] . r o w s [ 0 ] ) { v a r   l i s t = [ ] , c e l l s = r o w s [ 0 ] . c e l l s , l = c e l l s . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { v a r   p = f a l s e ; i f ( $ . m e t a d a t a & & ( $ ( $ h e a d e r s [ i ] ) . m e t a d a t a ( ) & & $ ( $ h e a d e r s [ i ] ) . m e t a d a t a ( ) . s o r t e r ) ) { p = g e t P a r s e r B y I d ( $ ( $ h e a d e r s [ i ] ) . m e t a d a t a ( ) . s o r t e r ) ; } e l s e   i f ( ( t a b l e . c o n f i g . h e a d e r s [ i ] & & t a b l e . c o n f i g . h e a d e r s [ i ] . s o r t e r ) ) { p = g e t P a r s e r B y I d ( t a b l e . c o n f i g . h e a d e r s [ i ] . s o r t e r ) ; } i f ( ! p ) { p = d e t e c t P a r s e r F o r C o l u m n ( t a b l e , c e l l s [ i ] ) ; } i f ( t a b l e . c o n f i g . d e b u g ) { p a r s e r s D e b u g + = " c o l u m n : " + i + "   p a r s e r : " + p . i d + " \ n " ; } l i s t . p u s h ( p ) ; } } i f ( t a b l e . c o n f i g . d e b u g ) { l o g ( p a r s e r s D e b u g ) ; } r e t u r n   l i s t ; } ; f u n c t i o n   d e t e c t P a r s e r F o r C o l u m n ( t a b l e , n o d e ) { v a r   l = p a r s e r s . l e n g t h ; f o r ( v a r   i = 1 ; i < l ; i + + ) { i f ( p a r s e r s [ i ] . i s ( $ . t r i m ( g e t E l e m e n t T e x t ( t a b l e . c o n f i g , n o d e ) ) , t a b l e , n o d e ) ) { r e t u r n   p a r s e r s [ i ] ; } } r e t u r n   p a r s e r s [ 0 ] ; } f u n c t i o n   g e t P a r s e r B y I d ( n a m e ) { v a r   l = p a r s e r s . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { i f ( p a r s e r s [ i ] . i d . t o L o w e r C a s e ( ) = = n a m e . t o L o w e r C a s e ( ) ) { r e t u r n   p a r s e r s [ i ] ; } } r e t u r n   f a l s e ; } f u n c t i o n   b u i l d C a c h e ( t a b l e ) { i f ( t a b l e . c o n f i g . d e b u g ) { v a r   c a c h e T i m e = n e w   D a t e ( ) ; } v a r   t o t a l R o w s = ( t a b l e . t B o d i e s [ 0 ] & & t a b l e . t B o d i e s [ 0 ] . r o w s . l e n g t h ) | | 0 , t o t a l C e l l s = ( t a b l e . t B o d i e s [ 0 ] . r o w s [ 0 ] & & t a b l e . t B o d i e s [ 0 ] . r o w s [ 0 ] . c e l l s . l e n g t h ) | | 0 , p a r s e r s = t a b l e . c o n f i g . p a r s e r s , c a c h e = { r o w : [ ] , n o r m a l i z e d : [ ] } ; f o r ( v a r   i = 0 ; i < t o t a l R o w s ; + + i ) { v a r   c = t a b l e . t B o d i e s [ 0 ] . r o w s [ i ] , c o l s = [ ] ; c a c h e . r o w . p u s h ( $ ( c ) ) ; f o r ( v a r   j = 0 ; j < t o t a l C e l l s ; + + j ) { c o l s . p u s h ( p a r s e r s [ j ] . f o r m a t ( g e t E l e m e n t T e x t ( t a b l e . c o n f i g , c . c e l l s [ j ] ) , t a b l e , c . c e l l s [ j ] ) ) ; } c o l s . p u s h ( i ) ; c a c h e . n o r m a l i z e d . p u s h ( c o l s ) ; c o l s = n u l l ; } ; i f ( t a b l e . c o n f i g . d e b u g ) { b e n c h m a r k ( " B u i l d i n g   c a c h e   f o r   " + t o t a l R o w s + "   r o w s : " , c a c h e T i m e ) ; } r e t u r n   c a c h e ; } ; f u n c t i o n   g e t E l e m e n t T e x t ( c o n f i g , n o d e ) { i f ( ! n o d e ) r e t u r n " " ; v a r   t = " " ; i f ( c o n f i g . t e x t E x t r a c t i o n = = " s i m p l e " ) { i f ( n o d e . c h i l d N o d e s [ 0 ] & & n o d e . c h i l d N o d e s [ 0 ] . h a s C h i l d N o d e s ( ) ) { t = n o d e . c h i l d N o d e s [ 0 ] . i n n e r H T M L ; } e l s e { t = n o d e . i n n e r H T M L ; } } e l s e { i f ( t y p e o f ( c o n f i g . t e x t E x t r a c t i o n ) = = " f u n c t i o n " ) { t = c o n f i g . t e x t E x t r a c t i o n ( n o d e ) ; } e l s e { t = $ ( n o d e ) . t e x t ( ) ; } } r e t u r n   t ; } f u n c t i o n   a p p e n d T o T a b l e ( t a b l e , c a c h e ) { i f ( t a b l e . c o n f i g . d e b u g ) { v a r   a p p e n d T i m e = n e w   D a t e ( ) } v a r   c = c a c h e , r = c . r o w , n = c . n o r m a l i z e d , t o t a l R o w s = n . l e n g t h , c h e c k C e l l = ( n [ 0 ] . l e n g t h - 1 ) , t a b l e B o d y = $ ( t a b l e . t B o d i e s [ 0 ] ) , r o w s = [ ] ; f o r ( v a r   i = 0 ; i < t o t a l R o w s ; i + + ) { r o w s . p u s h ( r [ n [ i ] [ c h e c k C e l l ] ] ) ; i f ( ! t a b l e . c o n f i g . a p p e n d e r ) { v a r   o = r [ n [ i ] [ c h e c k C e l l ] ] ; v a r   l = o . l e n g t h ; f o r ( v a r   j = 0 ; j < l ; j + + ) { t a b l e B o d y [ 0 ] . a p p e n d C h i l d ( o [ j ] ) ; } } } i f ( t a b l e . c o n f i g . a p p e n d e r ) { t a b l e . c o n f i g . a p p e n d e r ( t a b l e , r o w s ) ; } r o w s = n u l l ; i f ( t a b l e . c o n f i g . d e b u g ) { b e n c h m a r k ( " R e b u i l t   t a b l e : " , a p p e n d T i m e ) ; } a p p l y W i d g e t ( t a b l e ) ; s e t T i m e o u t ( f u n c t i o n ( ) { $ ( t a b l e ) . t r i g g e r ( " s o r t E n d " ) ; } , 0 ) ; } ; f u n c t i o n   b u i l d H e a d e r s ( t a b l e ) { i f ( t a b l e . c o n f i g . d e b u g ) { v a r   t i m e = n e w   D a t e ( ) ; } v a r   m e t a = ( $ . m e t a d a t a ) ? t r u e : f a l s e , t a b l e H e a d e r s R o w s = [ ] ; f o r ( v a r   i = 0 ; i < t a b l e . t H e a d . r o w s . l e n g t h ; i + + ) { t a b l e H e a d e r s R o w s [ i ] = 0 ; } ; $ t a b l e H e a d e r s = $ ( " t h e a d   t h " , t a b l e ) ; $ t a b l e H e a d e r s . e a c h ( f u n c t i o n ( i n d e x ) { t h i s . c o u n t = 0 ; t h i s . c o l u m n = i n d e x ; t h i s . o r d e r = f o r m a t S o r t i n g O r d e r ( t a b l e . c o n f i g . s o r t I n i t i a l O r d e r ) ; i f ( c h e c k H e a d e r M e t a d a t a ( t h i s ) | | c h e c k H e a d e r O p t i o n s ( t a b l e , i n d e x ) ) t h i s . s o r t D i s a b l e d = t r u e ; i f ( ! t h i s . s o r t D i s a b l e d ) { $ ( t h i s ) . a d d C l a s s ( t a b l e . c o n f i g . c s s H e a d e r ) ; } t a b l e . c o n f i g . h e a d e r L i s t [ i n d e x ] = t h i s ; } ) ; i f ( t a b l e . c o n f i g . d e b u g ) { b e n c h m a r k ( " B u i l t   h e a d e r s : " , t i m e ) ; l o g ( $ t a b l e H e a d e r s ) ; } r e t u r n   $ t a b l e H e a d e r s ; } ; f u n c t i o n   c h e c k C e l l C o l S p a n ( t a b l e , r o w s , r o w ) { v a r   a r r = [ ] , r = t a b l e . t H e a d . r o w s , c = r [ r o w ] . c e l l s ; f o r ( v a r   i = 0 ; i < c . l e n g t h ; i + + ) { v a r   c e l l = c [ i ] ; i f ( c e l l . c o l S p a n > 1 ) { a r r = a r r . c o n c a t ( c h e c k C e l l C o l S p a n ( t a b l e , h e a d e r A r r , r o w + + ) ) ; } e l s e { i f ( t a b l e . t H e a d . l e n g t h = = 1 | | ( c e l l . r o w S p a n > 1 | | ! r [ r o w + 1 ] ) ) { a r r . p u s h ( c e l l ) ; } } } r e t u r n   a r r ; } ; f u n c t i o n   c h e c k H e a d e r M e t a d a t a ( c e l l ) { i f ( ( $ . m e t a d a t a ) & & ( $ ( c e l l ) . m e t a d a t a ( ) . s o r t e r = = = f a l s e ) ) { r e t u r n   t r u e ; } ; r e t u r n   f a l s e ; } f u n c t i o n   c h e c k H e a d e r O p t i o n s ( t a b l e , i ) { i f ( ( t a b l e . c o n f i g . h e a d e r s [ i ] ) & & ( t a b l e . c o n f i g . h e a d e r s [ i ] . s o r t e r = = = f a l s e ) ) { r e t u r n   t r u e ; } ; r e t u r n   f a l s e ; } f u n c t i o n   a p p l y W i d g e t ( t a b l e ) { v a r   c = t a b l e . c o n f i g . w i d g e t s ; v a r   l = c . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { g e t W i d g e t B y I d ( c [ i ] ) . f o r m a t ( t a b l e ) ; } } f u n c t i o n   g e t W i d g e t B y I d ( n a m e ) { v a r   l = w i d g e t s . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { i f ( w i d g e t s [ i ] . i d . t o L o w e r C a s e ( ) = = n a m e . t o L o w e r C a s e ( ) ) { r e t u r n   w i d g e t s [ i ] ; } } } ; f u n c t i o n   f o r m a t S o r t i n g O r d e r ( v ) { i f ( t y p e o f ( v ) ! = " N u m b e r " ) { i = ( v . t o L o w e r C a s e ( ) = = " d e s c " ) ? 1 : 0 ; } e l s e { i = ( v = = ( 0 | | 1 ) ) ? v : 0 ; } r e t u r n   i ; } f u n c t i o n   i s V a l u e I n A r r a y ( v , a ) { v a r   l = a . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { i f ( a [ i ] [ 0 ] = = v ) { r e t u r n   t r u e ; } } r e t u r n   f a l s e ; } f u n c t i o n   s e t H e a d e r s C s s ( t a b l e , $ h e a d e r s , l i s t , c s s ) { $ h e a d e r s . r e m o v e C l a s s ( c s s [ 0 ] ) . r e m o v e C l a s s ( c s s [ 1 ] ) ; v a r   h = [ ] ; $ h e a d e r s . e a c h ( f u n c t i o n ( o f f s e t ) { i f ( ! t h i s . s o r t D i s a b l e d ) { h [ t h i s . c o l u m n ] = $ ( t h i s ) ; } } ) ; v a r   l = l i s t . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { h [ l i s t [ i ] [ 0 ] ] . a d d C l a s s ( c s s [ l i s t [ i ] [ 1 ] ] ) ; } } f u n c t i o n   f i x C o l u m n W i d t h ( t a b l e , $ h e a d e r s ) { v a r   c = t a b l e . c o n f i g ; i f ( c . w i d t h F i x e d ) { v a r   c o l g r o u p = $ ( ' < c o l g r o u p > ' ) ; $ ( " t r : f i r s t   t d " , t a b l e . t B o d i e s [ 0 ] ) . e a c h ( f u n c t i o n ( ) { c o l g r o u p . a p p e n d ( $ ( ' < c o l > ' ) . c s s ( ' w i d t h ' , $ ( t h i s ) . w i d t h ( ) ) ) ; } ) ; $ ( t a b l e ) . p r e p e n d ( c o l g r o u p ) ; } ; } f u n c t i o n   u p d a t e H e a d e r S o r t C o u n t ( t a b l e , s o r t L i s t ) { v a r   c = t a b l e . c o n f i g , l = s o r t L i s t . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { v a r   s = s o r t L i s t [ i ] , o = c . h e a d e r L i s t [ s [ 0 ] ] ; o . c o u n t = s [ 1 ] ; o . c o u n t + + ; } } f u n c t i o n   m u l t i s o r t ( t a b l e , s o r t L i s t , c a c h e ) { i f ( t a b l e . c o n f i g . d e b u g ) { v a r   s o r t T i m e = n e w   D a t e ( ) ; } v a r   d y n a m i c E x p = " v a r   s o r t W r a p p e r   =   f u n c t i o n ( a , b )   { " , l = s o r t L i s t . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { v a r   c = s o r t L i s t [ i ] [ 0 ] ; v a r   o r d e r = s o r t L i s t [ i ] [ 1 ] ; v a r   s = ( g e t C a c h e d S o r t T y p e ( t a b l e . c o n f i g . p a r s e r s , c ) = = " t e x t " ) ? ( ( o r d e r = = 0 ) ? " s o r t T e x t " : " s o r t T e x t D e s c " ) : ( ( o r d e r = = 0 ) ? " s o r t N u m e r i c " : " s o r t N u m e r i c D e s c " ) ; v a r   e = " e " + i ; d y n a m i c E x p + = " v a r   " + e + "   =   " + s + " ( a [ " + c + " ] , b [ " + c + " ] ) ;   " ; d y n a m i c E x p + = " i f ( " + e + " )   {   r e t u r n   " + e + " ;   }   " ; d y n a m i c E x p + = " e l s e   {   " ; } v a r   o r g O r d e r C o l = c a c h e . n o r m a l i z e d [ 0 ] . l e n g t h - 1 ; d y n a m i c E x p + = " r e t u r n   a [ " + o r g O r d e r C o l + " ] - b [ " + o r g O r d e r C o l + " ] ; " ; f o r ( v a r   i = 0 ; i < l ; i + + ) { d y n a m i c E x p + = " } ;   " ; } d y n a m i c E x p + = " r e t u r n   0 ;   " ; d y n a m i c E x p + = " } ;   " ; e v a l ( d y n a m i c E x p ) ; c a c h e . n o r m a l i z e d . s o r t ( s o r t W r a p p e r ) ; i f ( t a b l e . c o n f i g . d e b u g ) { b e n c h m a r k ( " S o r t i n g   o n   " + s o r t L i s t . t o S t r i n g ( ) + "   a n d   d i r   " + o r d e r + "   t i m e : " , s o r t T i m e ) ; } r e t u r n   c a c h e ; } ; f u n c t i o n   s o r t T e x t ( a , b ) { r e t u r n ( ( a < b ) ? - 1 : ( ( a > b ) ? 1 : 0 ) ) ; } ; f u n c t i o n   s o r t T e x t D e s c ( a , b ) { r e t u r n ( ( a < b ) ? - 1 : ( ( a > b ) ? 1 : 0 ) ) ; } ; f u n c t i o n   s o r t N u m e r i c ( a , b ) { r e t u r n   b - a ; } ; f u n c t i o n   s o r t N u m e r i c D e s c ( a , b ) { r e t u r n   b - a ; } ; f u n c t i o n   g e t C a c h e d S o r t T y p e ( p a r s e r s , i ) { r e t u r n   p a r s e r s [ i ] . t y p e ; } ; t h i s . c o n s t r u c t = f u n c t i o n ( s e t t i n g s ) { r e t u r n   t h i s . e a c h ( f u n c t i o n ( ) { i f ( ! t h i s . t H e a d | | ! t h i s . t B o d i e s ) r e t u r n ; v a r   $ t h i s , $ d o c u m e n t , $ h e a d e r s , c a c h e , c o n f i g , s h i f t D o w n = 0 , s o r t O r d e r ; t h i s . c o n f i g = { } ; c o n f i g = $ . e x t e n d ( t h i s . c o n f i g , $ . t a b l e s o r t e r . d e f a u l t s , s e t t i n g s ) ; $ t h i s = $ ( t h i s ) ; $ h e a d e r s = b u i l d H e a d e r s ( t h i s ) ; t h i s . c o n f i g . p a r s e r s = b u i l d P a r s e r C a c h e ( t h i s , $ h e a d e r s ) ; c a c h e = b u i l d C a c h e ( t h i s ) ; v a r   s o r t C S S = [ c o n f i g . c s s D e s c , c o n f i g . c s s A s c ] ; f i x C o l u m n W i d t h ( t h i s ) ; $ h e a d e r s . c l i c k ( f u n c t i o n ( e ) { $ t h i s . t r i g g e r ( " s o r t S t a r t " ) ; v a r   t o t a l R o w s = ( $ t h i s [ 0 ] . t B o d i e s [ 0 ] & & $ t h i s [ 0 ] . t B o d i e s [ 0 ] . r o w s . l e n g t h ) | | 0 ; i f ( ! t h i s . s o r t D i s a b l e d & & t o t a l R o w s > 0 ) { v a r   $ c e l l = $ ( t h i s ) ; v a r   i = t h i s . c o l u m n ; t h i s . o r d e r = t h i s . c o u n t + + % 2 ; i f ( ! e [ c o n f i g . s o r t M u l t i S o r t K e y ] ) { c o n f i g . s o r t L i s t = [ ] ; i f ( c o n f i g . s o r t F o r c e ! = n u l l ) { v a r   a = c o n f i g . s o r t F o r c e ; f o r ( v a r   j = 0 ; j < a . l e n g t h ; j + + ) { i f ( a [ j ] [ 0 ] ! = i ) { c o n f i g . s o r t L i s t . p u s h ( a [ j ] ) ; } } } c o n f i g . s o r t L i s t . p u s h ( [ i , t h i s . o r d e r ] ) ; } e l s e { i f ( i s V a l u e I n A r r a y ( i , c o n f i g . s o r t L i s t ) ) { f o r ( v a r   j = 0 ; j < c o n f i g . s o r t L i s t . l e n g t h ; j + + ) { v a r   s = c o n f i g . s o r t L i s t [ j ] , o = c o n f i g . h e a d e r L i s t [ s [ 0 ] ] ; i f ( s [ 0 ] = = i ) { o . c o u n t = s [ 1 ] ; o . c o u n t + + ; s [ 1 ] = o . c o u n t % 2 ; } } } e l s e { c o n f i g . s o r t L i s t . p u s h ( [ i , t h i s . o r d e r ] ) ; } } ; s e t T i m e o u t ( f u n c t i o n ( ) { s e t H e a d e r s C s s ( $ t h i s [ 0 ] , $ h e a d e r s , c o n f i g . s o r t L i s t , s o r t C S S ) ; a p p e n d T o T a b l e ( $ t h i s [ 0 ] , m u l t i s o r t ( $ t h i s [ 0 ] , c o n f i g . s o r t L i s t , c a c h e ) ) ; } , 1 ) ; r e t u r n   f a l s e ; } } ) . m o u s e d o w n ( f u n c t i o n ( ) { i f ( c o n f i g . c a n c e l S e l e c t i o n ) { t h i s . o n s e l e c t s t a r t = f u n c t i o n ( ) { r e t u r n   f a l s e } ; r e t u r n   f a l s e ; } } ) ; $ t h i s . b i n d ( " u p d a t e " , f u n c t i o n ( ) { t h i s . c o n f i g . p a r s e r s = b u i l d P a r s e r C a c h e ( t h i s , $ h e a d e r s ) ; c a c h e = b u i l d C a c h e ( t h i s ) ; } ) . b i n d ( " s o r t o n " , f u n c t i o n ( e , l i s t ) { $ ( t h i s ) . t r i g g e r ( " s o r t S t a r t " ) ; c o n f i g . s o r t L i s t = l i s t ; v a r   s o r t L i s t = c o n f i g . s o r t L i s t ; u p d a t e H e a d e r S o r t C o u n t ( t h i s , s o r t L i s t ) ; s e t H e a d e r s C s s ( t h i s , $ h e a d e r s , s o r t L i s t , s o r t C S S ) ; a p p e n d T o T a b l e ( t h i s , m u l t i s o r t ( t h i s , s o r t L i s t , c a c h e ) ) ; } ) . b i n d ( " a p p e n d C a c h e " , f u n c t i o n ( ) { a p p e n d T o T a b l e ( t h i s , c a c h e ) ; } ) . b i n d ( " a p p l y W i d g e t I d " , f u n c t i o n ( e , i d ) { g e t W i d g e t B y I d ( i d ) . f o r m a t ( t h i s ) ; } ) . b i n d ( " a p p l y W i d g e t s " , f u n c t i o n ( ) { a p p l y W i d g e t ( t h i s ) ; } ) ; i f ( $ . m e t a d a t a & & ( $ ( t h i s ) . m e t a d a t a ( ) & & $ ( t h i s ) . m e t a d a t a ( ) . s o r t l i s t ) ) { c o n f i g . s o r t L i s t = $ ( t h i s ) . m e t a d a t a ( ) . s o r t l i s t ; } i f ( c o n f i g . s o r t L i s t . l e n g t h > 0 ) { $ t h i s . t r i g g e r ( " s o r t o n " , [ c o n f i g . s o r t L i s t ] ) ; } a p p l y W i d g e t ( t h i s ) ; } ) ; } ; t h i s . a d d P a r s e r = f u n c t i o n ( p a r s e r ) { v a r   l = p a r s e r s . l e n g t h , a = t r u e ; f o r ( v a r   i = 0 ; i < l ; i + + ) { i f ( p a r s e r s [ i ] . i d . t o L o w e r C a s e ( ) = = p a r s e r . i d . t o L o w e r C a s e ( ) ) { a = f a l s e ; } } i f ( a ) { p a r s e r s . p u s h ( p a r s e r ) ; } ; } ; t h i s . a d d W i d g e t = f u n c t i o n ( w i d g e t ) { w i d g e t s . p u s h ( w i d g e t ) ; } ; t h i s . f o r m a t F l o a t = f u n c t i o n ( s ) { v a r   i = p a r s e F l o a t ( s ) ; r e t u r n ( i s N a N ( i ) ) ? 0 : i ; } ; t h i s . f o r m a t I n t = f u n c t i o n ( s ) { v a r   i = p a r s e I n t ( s ) ; r e t u r n ( i s N a N ( i ) ) ? 0 : i ; } ; t h i s . i s D i g i t = f u n c t i o n ( s , c o n f i g ) { v a r   D E C I M A L = ' \ \ ' + c o n f i g . d e c i m a l ; v a r   e x p = ' / ( ^ [ + ] ? 0 ( ' + D E C I M A L + ' 0 + ) ? $ ) | ( ^ ( [ - + ] ? [ 1 - 9 ] [ 0 - 9 ] * ) $ ) | ( ^ ( [ - + ] ? ( ( 0 ? | [ 1 - 9 ] [ 0 - 9 ] * ) ' + D E C I M A L + ' ( 0 * [ 1 - 9 ] [ 0 - 9 ] * ) ) ) $ ) | ( ^ [ - + ] ? [ 1 - 9 ] + [ 0 - 9 ] * ' + D E C I M A L + ' 0 + $ ) / ' ; r e t u r n   R e g E x p ( e x p ) . t e s t ( $ . t r i m ( s ) ) ; } ; t h i s . c l e a r T a b l e B o d y = f u n c t i o n ( t a b l e ) { i f ( $ . b r o w s e r . m s i e ) { f u n c t i o n   e m p t y ( ) { w h i l e ( t h i s . f i r s t C h i l d ) t h i s . r e m o v e C h i l d ( t h i s . f i r s t C h i l d ) ; } e m p t y . a p p l y ( t a b l e . t B o d i e s [ 0 ] ) ; } e l s e { t a b l e . t B o d i e s [ 0 ] . i n n e r H T M L = " " ; } } ; } } ) ; $ . f n . e x t e n d ( { t a b l e s o r t e r : $ . t a b l e s o r t e r . c o n s t r u c t } ) ; v a r   t s = $ . t a b l e s o r t e r ; t s . a d d P a r s e r ( { i d : " t e x t " , i s : f u n c t i o n ( s ) { r e t u r n   t r u e ; } , f o r m a t : f u n c t i o n ( s ) { r e t u r n   $ . t r i m ( s . t o L o w e r C a s e ( ) ) ; } , t y p e : " t e x t " } ) ; t s . a d d P a r s e r ( { i d : " d i g i t " , i s : f u n c t i o n ( s , t a b l e ) { v a r   c = t a b l e . c o n f i g ; r e t u r n   $ . t a b l e s o r t e r . i s D i g i t ( s , c ) ; } , f o r m a t : f u n c t i o n ( s ) { r e t u r n   $ . t a b l e s o r t e r . f o r m a t F l o a t ( s ) ; } , t y p e : " n u m e r i c " } ) ; t s . a d d P a r s e r ( { i d : " c u r r e n c y " , i s : f u n c t i o n ( s ) { r e t u r n / ^ [ Â £ $ â  ¬ ? . ] / . t e s t ( s ) ; } , f o r m a t : f u n c t i o n ( s ) { r e t u r n   $ . t a b l e s o r t e r . f o r m a t F l o a t ( s . r e p l a c e ( n e w   R e g E x p ( / [ ^ 0 - 9 . ] / g ) , " " ) ) ; } , t y p e : " n u m e r i c " } ) ; t s . a d d P a r s e r ( { i d : " i p A d d r e s s " , i s : f u n c t i o n ( s ) { r e t u r n / ^ \ d { 2 , 3 } [ \ . ] \ d { 2 , 3 } [ \ . ] \ d { 2 , 3 } [ \ . ] \ d { 2 , 3 } $ / . t e s t ( s ) ; } , f o r m a t : f u n c t i o n ( s ) { v a r   a = s . s p l i t ( " . " ) , r = " " , l = a . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { v a r   i t e m = a [ i ] ; i f ( i t e m . l e n g t h = = 2 ) { r + = " 0 " + i t e m ; } e l s e { r + = i t e m ; } } r e t u r n   $ . t a b l e s o r t e r . f o r m a t F l o a t ( r ) ; } , t y p e : " n u m e r i c " } ) ; t s . a d d P a r s e r ( { i d : " u r l " , i s : f u n c t i o n ( s ) { r e t u r n / ^ ( h t t p s ? | f t p | f i l e ) : \ / \ / $ / . t e s t ( s ) ; } , f o r m a t : f u n c t i o n ( s ) { r e t u r n   j Q u e r y . t r i m ( s . r e p l a c e ( n e w   R e g E x p ( / ( h t t p s ? | f t p | f i l e ) : \ / \ / / ) , ' ' ) ) ; } , t y p e : " t e x t " } ) ; t s . a d d P a r s e r ( { i d : " i s o D a t e " , i s : f u n c t i o n ( s ) { r e t u r n / ^ \ d { 4 } [ \ / - ] \ d { 1 , 2 } [ \ / - ] \ d { 1 , 2 } $ / . t e s t ( s ) ; } , f o r m a t : f u n c t i o n ( s ) { r e t u r n   $ . t a b l e s o r t e r . f o r m a t F l o a t ( ( s ! = " " ) ? n e w   D a t e ( s . r e p l a c e ( n e w   R e g E x p ( / - / g ) , " / " ) ) . g e t T i m e ( ) : " 0 " ) ; } , t y p e : " n u m e r i c " } ) ; t s . a d d P a r s e r ( { i d : " p e r c e n t " , i s : f u n c t i o n ( s ) { r e t u r n / \ % $ / . t e s t ( $ . t r i m ( s ) ) ; } , f o r m a t : f u n c t i o n ( s ) { r e t u r n   $ . t a b l e s o r t e r . f o r m a t F l o a t ( s . r e p l a c e ( n e w   R e g E x p ( / % / g ) , " " ) ) ; } , t y p e : " n u m e r i c " } ) ; t s . a d d P a r s e r ( { i d : " u s L o n g D a t e " , i s : f u n c t i o n ( s ) { r e t u r n   s . m a t c h ( n e w   R e g E x p ( / ^ [ A - Z a - z ] { 3 , 1 0 } \ . ?   [ 0 - 9 ] { 1 , 2 } ,   ( [ 0 - 9 ] { 4 } | ' ? [ 0 - 9 ] { 2 } )   ( ( [ 0 - 2 ] ? [ 0 - 9 ] : [ 0 - 5 ] [ 0 - 9 ] ) | ( [ 0 - 1 ] ? [ 0 - 9 ] : [ 0 - 5 ] [ 0 - 9 ] \ s ( A M | P M ) ) ) $ / ) ) ; } , f o r m a t : f u n c t i o n ( s ) { r e t u r n   $ . t a b l e s o r t e r . f o r m a t F l o a t ( n e w   D a t e ( s ) . g e t T i m e ( ) ) ; } , t y p e : " n u m e r i c " } ) ; t s . a d d P a r s e r ( { i d : " s h o r t D a t e " , i s : f u n c t i o n ( s ) { r e t u r n / \ d { 1 , 2 } [ \ / \ - ] \ d { 1 , 2 } [ \ / \ - ] \ d { 2 , 4 } / . t e s t ( s ) ; } , f o r m a t : f u n c t i o n ( s , t a b l e ) { v a r   c = t a b l e . c o n f i g ; s = s . r e p l a c e ( / \ - / g , " / " ) ; i f ( c . d a t e F o r m a t = = " u s " ) { s = s . r e p l a c e ( / ( \ d { 1 , 2 } ) [ \ / \ - ] ( \ d { 1 , 2 } ) [ \ / \ - ] ( \ d { 4 } ) / , " $ 3 / $ 1 / $ 2 " ) ; } e l s e   i f ( c . d a t e F o r m a t = = " u k " ) { s = s . r e p l a c e ( / ( \ d { 1 , 2 } ) [ \ / \ - ] ( \ d { 1 , 2 } ) [ \ / \ - ] ( \ d { 4 } ) / , " $ 3 / $ 2 / $ 1 " ) ; } e l s e   i f ( c . d a t e F o r m a t = = " d d / m m / y y " | | c . d a t e F o r m a t = = " d d - m m - y y " ) { s = s . r e p l a c e ( / ( \ d { 1 , 2 } ) [ \ / \ - ] ( \ d { 1 , 2 } ) [ \ / \ - ] ( \ d { 2 } ) / , " $ 1 / $ 2 / $ 3 " ) ; } r e t u r n   $ . t a b l e s o r t e r . f o r m a t F l o a t ( n e w   D a t e ( s ) . g e t T i m e ( ) ) ; } , t y p e : " n u m e r i c " } ) ; t s . a d d P a r s e r ( { i d : " t i m e " , i s : f u n c t i o n ( s ) { r e t u r n / ^ ( ( [ 0 - 2 ] ? [ 0 - 9 ] : [ 0 - 5 ] [ 0 - 9 ] ) | ( [ 0 - 1 ] ? [ 0 - 9 ] : [ 0 - 5 ] [ 0 - 9 ] \ s ( a m | p m ) ) ) $ / . t e s t ( s ) ; } , f o r m a t : f u n c t i o n ( s ) { r e t u r n   $ . t a b l e s o r t e r . f o r m a t F l o a t ( n e w   D a t e ( " 2 0 0 0 / 0 1 / 0 1   " + s ) . g e t T i m e ( ) ) ; } , t y p e : " n u m e r i c " } ) ; t s . a d d P a r s e r ( { i d : " m e t a d a t a " , i s : f u n c t i o n ( s ) { r e t u r n   f a l s e ; } , f o r m a t : f u n c t i o n ( s , t a b l e , c e l l ) { v a r   c = t a b l e . c o n f i g , p = ( ! c . p a r s e r M e t a d a t a N a m e ) ? ' s o r t V a l u e ' : c . p a r s e r M e t a d a t a N a m e ; r e t u r n   $ ( c e l l ) . m e t a d a t a ( ) [ p ] ; } , t y p e : " n u m e r i c " } ) ; t s . a d d W i d g e t ( { i d : " z e b r a " , f o r m a t : f u n c t i o n ( t a b l e ) { i f ( t a b l e . c o n f i g . d e b u g ) { v a r   t i m e = n e w   D a t e ( ) ; } $ ( " t r : v i s i b l e " , t a b l e . t B o d i e s [ 0 ] ) . f i l t e r ( ' : e v e n ' ) . r e m o v e C l a s s ( t a b l e . c o n f i g . w i d g e t Z e b r a . c s s [ 1 ] ) . a d d C l a s s ( t a b l e . c o n f i g . w i d g e t Z e b r a . c s s [ 0 ] ) . e n d ( ) . f i l t e r ( ' : o d d ' ) . r e m o v e C l a s s ( t a b l e . c o n f i g . w i d g e t Z e b r a . c s s [ 0 ] ) . a d d C l a s s ( t a b l e . c o n f i g . w i d g e t Z e b r a . c s s [ 1 ] ) ; i f ( t a b l e . c o n f i g . d e b u g ) { $ . t a b l e s o r t e r . b e n c h m a r k ( " A p p l y i n g   Z e b r a   w i d g e t " , t i m e ) ; } } } ) ; } ) ( j Q u e r y ) ; 
 / / ( f u n c t i o n ( $ ) { $ . e x t e n d ( { t a b l e s o r t e r : n e w   f u n c t i o n ( ) { v a r   p a r s e r s = [ ] , w i d g e t s = [ ] ; t h i s . d e f a u l t s = { c s s H e a d e r : " h e a d e r " , c s s A s c : " h e a d e r S o r t U p " , c s s D e s c : " h e a d e r S o r t D o w n " , s o r t I n i t i a l O r d e r : " a s c " , s o r t M u l t i S o r t K e y : " s h i f t K e y " , s o r t F o r c e : n u l l , s o r t A p p e n d : n u l l , t e x t E x t r a c t i o n : " s i m p l e " , p a r s e r s : { } , w i d g e t s : [ ] , w i d g e t Z e b r a : { c s s : [ " e v e n " , " o d d " ] } , h e a d e r s : { } , w i d t h F i x e d : f a l s e , c a n c e l S e l e c t i o n : t r u e , s o r t L i s t : [ ] , h e a d e r L i s t : [ ] , d a t e F o r m a t : " u s " , d e c i m a l : ' . ' , d e b u g : f a l s e } ; f u n c t i o n   b e n c h m a r k ( s , d ) { l o g ( s + " , " + ( n e w   D a t e ( ) . g e t T i m e ( ) - d . g e t T i m e ( ) ) + " m s " ) ; } t h i s . b e n c h m a r k = b e n c h m a r k ; f u n c t i o n   l o g ( s ) { i f ( t y p e o f   c o n s o l e ! = " u n d e f i n e d " & & t y p e o f   c o n s o l e . d e b u g ! = " u n d e f i n e d " ) { c o n s o l e . l o g ( s ) ; } e l s e { a l e r t ( s ) ; } } f u n c t i o n   b u i l d P a r s e r C a c h e ( t a b l e , $ h e a d e r s ) { i f ( t a b l e . c o n f i g . d e b u g ) { v a r   p a r s e r s D e b u g = " " ; } v a r   r o w s = t a b l e . t B o d i e s [ 0 ] . r o w s ; i f ( t a b l e . t B o d i e s [ 0 ] . r o w s [ 0 ] ) { v a r   l i s t = [ ] , c e l l s = r o w s [ 0 ] . c e l l s , l = c e l l s . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { v a r   p = f a l s e ; i f ( $ . m e t a d a t a & & ( $ ( $ h e a d e r s [ i ] ) . m e t a d a t a ( ) & & $ ( $ h e a d e r s [ i ] ) . m e t a d a t a ( ) . s o r t e r ) ) { p = g e t P a r s e r B y I d ( $ ( $ h e a d e r s [ i ] ) . m e t a d a t a ( ) . s o r t e r ) ; } e l s e   i f ( ( t a b l e . c o n f i g . h e a d e r s [ i ] & & t a b l e . c o n f i g . h e a d e r s [ i ] . s o r t e r ) ) { p = g e t P a r s e r B y I d ( t a b l e . c o n f i g . h e a d e r s [ i ] . s o r t e r ) ; } i f ( ! p ) { p = d e t e c t P a r s e r F o r C o l u m n ( t a b l e , c e l l s [ i ] ) ; } i f ( t a b l e . c o n f i g . d e b u g ) { p a r s e r s D e b u g + = " c o l u m n : " + i + "   p a r s e r : " + p . i d + " \ n " ; } l i s t . p u s h ( p ) ; } } i f ( t a b l e . c o n f i g . d e b u g ) { l o g ( p a r s e r s D e b u g ) ; } r e t u r n   l i s t ; } ; f u n c t i o n   d e t e c t P a r s e r F o r C o l u m n ( t a b l e , n o d e ) { v a r   l = p a r s e r s . l e n g t h ; f o r ( v a r   i = 1 ; i < l ; i + + ) { i f ( p a r s e r s [ i ] . i s ( $ . t r i m ( g e t E l e m e n t T e x t ( t a b l e . c o n f i g , n o d e ) ) , t a b l e , n o d e ) ) { r e t u r n   p a r s e r s [ i ] ; } } r e t u r n   p a r s e r s [ 0 ] ; } f u n c t i o n   g e t P a r s e r B y I d ( n a m e ) { v a r   l = p a r s e r s . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { i f ( p a r s e r s [ i ] . i d . t o L o w e r C a s e ( ) = = n a m e . t o L o w e r C a s e ( ) ) { r e t u r n   p a r s e r s [ i ] ; } } r e t u r n   f a l s e ; } f u n c t i o n   b u i l d C a c h e ( t a b l e ) { i f ( t a b l e . c o n f i g . d e b u g ) { v a r   c a c h e T i m e = n e w   D a t e ( ) ; } v a r   t o t a l R o w s = ( t a b l e . t B o d i e s [ 0 ] & & t a b l e . t B o d i e s [ 0 ] . r o w s . l e n g t h ) | | 0 , t o t a l C e l l s = ( t a b l e . t B o d i e s [ 0 ] . r o w s [ 0 ] & & t a b l e . t B o d i e s [ 0 ] . r o w s [ 0 ] . c e l l s . l e n g t h ) | | 0 , p a r s e r s = t a b l e . c o n f i g . p a r s e r s , c a c h e = { r o w : [ ] , n o r m a l i z e d : [ ] } ; f o r ( v a r   i = 0 ; i < t o t a l R o w s ; + + i ) { v a r   c = t a b l e . t B o d i e s [ 0 ] . r o w s [ i ] , c o l s = [ ] ; c a c h e . r o w . p u s h ( $ ( c ) ) ; f o r ( v a r   j = 0 ; j < t o t a l C e l l s ; + + j ) { c o l s . p u s h ( p a r s e r s [ j ] . f o r m a t ( g e t E l e m e n t T e x t ( t a b l e . c o n f i g , c . c e l l s [ j ] ) , t a b l e , c . c e l l s [ j ] ) ) ; } c o l s . p u s h ( i ) ; c a c h e . n o r m a l i z e d . p u s h ( c o l s ) ; c o l s = n u l l ; } ; i f ( t a b l e . c o n f i g . d e b u g ) { b e n c h m a r k ( " B u i l d i n g   c a c h e   f o r   " + t o t a l R o w s + "   r o w s : " , c a c h e T i m e ) ; } r e t u r n   c a c h e ; } ; f u n c t i o n   g e t E l e m e n t T e x t ( c o n f i g , n o d e ) { i f ( ! n o d e ) r e t u r n " " ; v a r   t = " " ; i f ( c o n f i g . t e x t E x t r a c t i o n = = " s i m p l e " ) { i f ( n o d e . c h i l d N o d e s [ 0 ] & & n o d e . c h i l d N o d e s [ 0 ] . h a s C h i l d N o d e s ( ) ) { t = n o d e . c h i l d N o d e s [ 0 ] . i n n e r H T M L ; } e l s e { t = n o d e . i n n e r H T M L ; } } e l s e { i f ( t y p e o f ( c o n f i g . t e x t E x t r a c t i o n ) = = " f u n c t i o n " ) { t = c o n f i g . t e x t E x t r a c t i o n ( n o d e ) ; } e l s e { t = $ ( n o d e ) . t e x t ( ) ; } } r e t u r n   t ; } f u n c t i o n   a p p e n d T o T a b l e ( t a b l e , c a c h e ) { i f ( t a b l e . c o n f i g . d e b u g ) { v a r   a p p e n d T i m e = n e w   D a t e ( ) } v a r   c = c a c h e , r = c . r o w , n = c . n o r m a l i z e d , t o t a l R o w s = n . l e n g t h , c h e c k C e l l = ( n [ 0 ] . l e n g t h - 1 ) , t a b l e B o d y = $ ( t a b l e . t B o d i e s [ 0 ] ) , r o w s = [ ] ; f o r ( v a r   i = 0 ; i < t o t a l R o w s ; i + + ) { r o w s . p u s h ( r [ n [ i ] [ c h e c k C e l l ] ] ) ; i f ( ! t a b l e . c o n f i g . a p p e n d e r ) { v a r   o = r [ n [ i ] [ c h e c k C e l l ] ] ; v a r   l = o . l e n g t h ; f o r ( v a r   j = 0 ; j < l ; j + + ) { t a b l e B o d y [ 0 ] . a p p e n d C h i l d ( o [ j ] ) ; } } } i f ( t a b l e . c o n f i g . a p p e n d e r ) { t a b l e . c o n f i g . a p p e n d e r ( t a b l e , r o w s ) ; } r o w s = n u l l ; i f ( t a b l e . c o n f i g . d e b u g ) { b e n c h m a r k ( " R e b u i l t   t a b l e : " , a p p e n d T i m e ) ; } a p p l y W i d g e t ( t a b l e ) ; s e t T i m e o u t ( f u n c t i o n ( ) { $ ( t a b l e ) . t r i g g e r ( " s o r t E n d " ) ; } , 0 ) ; } ; f u n c t i o n   b u i l d H e a d e r s ( t a b l e ) { i f ( t a b l e . c o n f i g . d e b u g ) { v a r   t i m e = n e w   D a t e ( ) ; } v a r   m e t a = ( $ . m e t a d a t a ) ? t r u e : f a l s e , t a b l e H e a d e r s R o w s = [ ] ; f o r ( v a r   i = 0 ; i < t a b l e . t H e a d . r o w s . l e n g t h ; i + + ) { t a b l e H e a d e r s R o w s [ i ] = 0 ; } ; $ t a b l e H e a d e r s = $ ( " t h e a d   t h " , t a b l e ) ; $ t a b l e H e a d e r s . e a c h ( f u n c t i o n ( i n d e x ) { t h i s . c o u n t = 0 ; t h i s . c o l u m n = i n d e x ; t h i s . o r d e r = f o r m a t S o r t i n g O r d e r ( t a b l e . c o n f i g . s o r t I n i t i a l O r d e r ) ; i f ( c h e c k H e a d e r M e t a d a t a ( t h i s ) | | c h e c k H e a d e r O p t i o n s ( t a b l e , i n d e x ) ) t h i s . s o r t D i s a b l e d = t r u e ; i f ( ! t h i s . s o r t D i s a b l e d ) { $ ( t h i s ) . a d d C l a s s ( t a b l e . c o n f i g . c s s H e a d e r ) ; } t a b l e . c o n f i g . h e a d e r L i s t [ i n d e x ] = t h i s ; } ) ; i f ( t a b l e . c o n f i g . d e b u g ) { b e n c h m a r k ( " B u i l t   h e a d e r s : " , t i m e ) ; l o g ( $ t a b l e H e a d e r s ) ; } r e t u r n   $ t a b l e H e a d e r s ; } ; f u n c t i o n   c h e c k C e l l C o l S p a n ( t a b l e , r o w s , r o w ) { v a r   a r r = [ ] , r = t a b l e . t H e a d . r o w s , c = r [ r o w ] . c e l l s ; f o r ( v a r   i = 0 ; i < c . l e n g t h ; i + + ) { v a r   c e l l = c [ i ] ; i f ( c e l l . c o l S p a n > 1 ) { a r r = a r r . c o n c a t ( c h e c k C e l l C o l S p a n ( t a b l e , h e a d e r A r r , r o w + + ) ) ; } e l s e { i f ( t a b l e . t H e a d . l e n g t h = = 1 | | ( c e l l . r o w S p a n > 1 | | ! r [ r o w + 1 ] ) ) { a r r . p u s h ( c e l l ) ; } } } r e t u r n   a r r ; } ; f u n c t i o n   c h e c k H e a d e r M e t a d a t a ( c e l l ) { i f ( ( $ . m e t a d a t a ) & & ( $ ( c e l l ) . m e t a d a t a ( ) . s o r t e r = = = f a l s e ) ) { r e t u r n   t r u e ; } ; r e t u r n   f a l s e ; } f u n c t i o n   c h e c k H e a d e r O p t i o n s ( t a b l e , i ) { i f ( ( t a b l e . c o n f i g . h e a d e r s [ i ] ) & & ( t a b l e . c o n f i g . h e a d e r s [ i ] . s o r t e r = = = f a l s e ) ) { r e t u r n   t r u e ; } ; r e t u r n   f a l s e ; } f u n c t i o n   a p p l y W i d g e t ( t a b l e ) { v a r   c = t a b l e . c o n f i g . w i d g e t s ; v a r   l = c . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { g e t W i d g e t B y I d ( c [ i ] ) . f o r m a t ( t a b l e ) ; } } f u n c t i o n   g e t W i d g e t B y I d ( n a m e ) { v a r   l = w i d g e t s . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { i f ( w i d g e t s [ i ] . i d . t o L o w e r C a s e ( ) = = n a m e . t o L o w e r C a s e ( ) ) { r e t u r n   w i d g e t s [ i ] ; } } } ; f u n c t i o n   f o r m a t S o r t i n g O r d e r ( v ) { i f ( t y p e o f ( v ) ! = " N u m b e r " ) { i = ( v . t o L o w e r C a s e ( ) = = " d e s c " ) ? 1 : 0 ; } e l s e { i = ( v = = ( 0 | | 1 ) ) ? v : 0 ; } r e t u r n   i ; } f u n c t i o n   i s V a l u e I n A r r a y ( v , a ) { v a r   l = a . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { i f ( a [ i ] [ 0 ] = = v ) { r e t u r n   t r u e ; } } r e t u r n   f a l s e ; } f u n c t i o n   s e t H e a d e r s C s s ( t a b l e , $ h e a d e r s , l i s t , c s s ) { $ h e a d e r s . r e m o v e C l a s s ( c s s [ 0 ] ) . r e m o v e C l a s s ( c s s [ 1 ] ) ; v a r   h = [ ] ; $ h e a d e r s . e a c h ( f u n c t i o n ( o f f s e t ) { i f ( ! t h i s . s o r t D i s a b l e d ) { h [ t h i s . c o l u m n ] = $ ( t h i s ) ; } } ) ; v a r   l = l i s t . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { h [ l i s t [ i ] [ 0 ] ] . a d d C l a s s ( c s s [ l i s t [ i ] [ 1 ] ] ) ; } } f u n c t i o n   f i x C o l u m n W i d t h ( t a b l e , $ h e a d e r s ) { v a r   c = t a b l e . c o n f i g ; i f ( c . w i d t h F i x e d ) { v a r   c o l g r o u p = $ ( ' < c o l g r o u p > ' ) ; $ ( " t r : f i r s t   t d " , t a b l e . t B o d i e s [ 0 ] ) . e a c h ( f u n c t i o n ( ) { c o l g r o u p . a p p e n d ( $ ( ' < c o l > ' ) . c s s ( ' w i d t h ' , $ ( t h i s ) . w i d t h ( ) ) ) ; } ) ; $ ( t a b l e ) . p r e p e n d ( c o l g r o u p ) ; } ; } f u n c t i o n   u p d a t e H e a d e r S o r t C o u n t ( t a b l e , s o r t L i s t ) { v a r   c = t a b l e . c o n f i g , l = s o r t L i s t . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { v a r   s = s o r t L i s t [ i ] , o = c . h e a d e r L i s t [ s [ 0 ] ] ; o . c o u n t = s [ 1 ] ; o . c o u n t + + ; } } f u n c t i o n   m u l t i s o r t ( t a b l e , s o r t L i s t , c a c h e ) { i f ( t a b l e . c o n f i g . d e b u g ) { v a r   s o r t T i m e = n e w   D a t e ( ) ; } v a r   d y n a m i c E x p = " v a r   s o r t W r a p p e r   =   f u n c t i o n ( a , b )   { " , l = s o r t L i s t . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { v a r   c = s o r t L i s t [ i ] [ 0 ] ; v a r   o r d e r = s o r t L i s t [ i ] [ 1 ] ; v a r   s = ( g e t C a c h e d S o r t T y p e ( t a b l e . c o n f i g . p a r s e r s , c ) = = " t e x t " ) ? ( ( o r d e r = = 0 ) ? " s o r t T e x t " : " s o r t T e x t D e s c " ) : ( ( o r d e r = = 0 ) ? " s o r t N u m e r i c " : " s o r t N u m e r i c D e s c " ) ; v a r   e = " e " + i ; d y n a m i c E x p + = " v a r   " + e + "   =   " + s + " ( a [ " + c + " ] , b [ " + c + " ] ) ;   " ; d y n a m i c E x p + = " i f ( " + e + " )   {   r e t u r n   " + e + " ;   }   " ; d y n a m i c E x p + = " e l s e   {   " ; } v a r   o r g O r d e r C o l = c a c h e . n o r m a l i z e d [ 0 ] . l e n g t h - 1 ; d y n a m i c E x p + = " r e t u r n   a [ " + o r g O r d e r C o l + " ] - b [ " + o r g O r d e r C o l + " ] ; " ; f o r ( v a r   i = 0 ; i < l ; i + + ) { d y n a m i c E x p + = " } ;   " ; } d y n a m i c E x p + = " r e t u r n   0 ;   " ; d y n a m i c E x p + = " } ;   " ; e v a l ( d y n a m i c E x p ) ; c a c h e . n o r m a l i z e d . s o r t ( s o r t W r a p p e r ) ; i f ( t a b l e . c o n f i g . d e b u g ) { b e n c h m a r k ( " S o r t i n g   o n   " + s o r t L i s t . t o S t r i n g ( ) + "   a n d   d i r   " + o r d e r + "   t i m e : " , s o r t T i m e ) ; } r e t u r n   c a c h e ; } ; f u n c t i o n   s o r t T e x t ( a , b ) { r e t u r n ( ( a < b ) ? - 1 : ( ( a > b ) ? 1 : 0 ) ) ; } ; f u n c t i o n   s o r t T e x t D e s c ( a , b ) { r e t u r n ( ( b < a ) ? - 1 : ( ( b > a ) ? 1 : 0 ) ) ; } ; f u n c t i o n   s o r t N u m e r i c ( a , b ) { r e t u r n   a - b ; } ; f u n c t i o n   s o r t N u m e r i c D e s c ( a , b ) { r e t u r n   b - a ; } ; f u n c t i o n   g e t C a c h e d S o r t T y p e ( p a r s e r s , i ) { r e t u r n   p a r s e r s [ i ] . t y p e ; } ; t h i s . c o n s t r u c t = f u n c t i o n ( s e t t i n g s ) { r e t u r n   t h i s . e a c h ( f u n c t i o n ( ) { i f ( ! t h i s . t H e a d | | ! t h i s . t B o d i e s ) r e t u r n ; v a r   $ t h i s , $ d o c u m e n t , $ h e a d e r s , c a c h e , c o n f i g , s h i f t D o w n = 0 , s o r t O r d e r ; t h i s . c o n f i g = { } ; c o n f i g = $ . e x t e n d ( t h i s . c o n f i g , $ . t a b l e s o r t e r . d e f a u l t s , s e t t i n g s ) ; $ t h i s = $ ( t h i s ) ; $ h e a d e r s = b u i l d H e a d e r s ( t h i s ) ; t h i s . c o n f i g . p a r s e r s = b u i l d P a r s e r C a c h e ( t h i s , $ h e a d e r s ) ; c a c h e = b u i l d C a c h e ( t h i s ) ; v a r   s o r t C S S = [ c o n f i g . c s s D e s c , c o n f i g . c s s A s c ] ; f i x C o l u m n W i d t h ( t h i s ) ; $ h e a d e r s . c l i c k ( f u n c t i o n ( e ) { $ t h i s . t r i g g e r ( " s o r t S t a r t " ) ; v a r   t o t a l R o w s = ( $ t h i s [ 0 ] . t B o d i e s [ 0 ] & & $ t h i s [ 0 ] . t B o d i e s [ 0 ] . r o w s . l e n g t h ) | | 0 ; i f ( ! t h i s . s o r t D i s a b l e d & & t o t a l R o w s > 0 ) { v a r   $ c e l l = $ ( t h i s ) ; v a r   i = t h i s . c o l u m n ; t h i s . o r d e r = t h i s . c o u n t + + % 2 ; i f ( ! e [ c o n f i g . s o r t M u l t i S o r t K e y ] ) { c o n f i g . s o r t L i s t = [ ] ; i f ( c o n f i g . s o r t F o r c e ! = n u l l ) { v a r   a = c o n f i g . s o r t F o r c e ; f o r ( v a r   j = 0 ; j < a . l e n g t h ; j + + ) { i f ( a [ j ] [ 0 ] ! = i ) { c o n f i g . s o r t L i s t . p u s h ( a [ j ] ) ; } } } c o n f i g . s o r t L i s t . p u s h ( [ i , t h i s . o r d e r ] ) ; } e l s e { i f ( i s V a l u e I n A r r a y ( i , c o n f i g . s o r t L i s t ) ) { f o r ( v a r   j = 0 ; j < c o n f i g . s o r t L i s t . l e n g t h ; j + + ) { v a r   s = c o n f i g . s o r t L i s t [ j ] , o = c o n f i g . h e a d e r L i s t [ s [ 0 ] ] ; i f ( s [ 0 ] = = i ) { o . c o u n t = s [ 1 ] ; o . c o u n t + + ; s [ 1 ] = o . c o u n t % 2 ; } } } e l s e { c o n f i g . s o r t L i s t . p u s h ( [ i , t h i s . o r d e r ] ) ; } } ; s e t T i m e o u t ( f u n c t i o n ( ) { s e t H e a d e r s C s s ( $ t h i s [ 0 ] , $ h e a d e r s , c o n f i g . s o r t L i s t , s o r t C S S ) ; a p p e n d T o T a b l e ( $ t h i s [ 0 ] , m u l t i s o r t ( $ t h i s [ 0 ] , c o n f i g . s o r t L i s t , c a c h e ) ) ; } , 1 ) ; r e t u r n   f a l s e ; } } ) . m o u s e d o w n ( f u n c t i o n ( ) { i f ( c o n f i g . c a n c e l S e l e c t i o n ) { t h i s . o n s e l e c t s t a r t = f u n c t i o n ( ) { r e t u r n   f a l s e } ; r e t u r n   f a l s e ; } } ) ; $ t h i s . b i n d ( " u p d a t e " , f u n c t i o n ( ) { t h i s . c o n f i g . p a r s e r s = b u i l d P a r s e r C a c h e ( t h i s , $ h e a d e r s ) ; c a c h e = b u i l d C a c h e ( t h i s ) ; } ) . b i n d ( " s o r t o n " , f u n c t i o n ( e , l i s t ) { $ ( t h i s ) . t r i g g e r ( " s o r t S t a r t " ) ; c o n f i g . s o r t L i s t = l i s t ; v a r   s o r t L i s t = c o n f i g . s o r t L i s t ; u p d a t e H e a d e r S o r t C o u n t ( t h i s , s o r t L i s t ) ; s e t H e a d e r s C s s ( t h i s , $ h e a d e r s , s o r t L i s t , s o r t C S S ) ; a p p e n d T o T a b l e ( t h i s , m u l t i s o r t ( t h i s , s o r t L i s t , c a c h e ) ) ; } ) . b i n d ( " a p p e n d C a c h e " , f u n c t i o n ( ) { a p p e n d T o T a b l e ( t h i s , c a c h e ) ; } ) . b i n d ( " a p p l y W i d g e t I d " , f u n c t i o n ( e , i d ) { g e t W i d g e t B y I d ( i d ) . f o r m a t ( t h i s ) ; } ) . b i n d ( " a p p l y W i d g e t s " , f u n c t i o n ( ) { a p p l y W i d g e t ( t h i s ) ; } ) ; i f ( $ . m e t a d a t a & & ( $ ( t h i s ) . m e t a d a t a ( ) & & $ ( t h i s ) . m e t a d a t a ( ) . s o r t l i s t ) ) { c o n f i g . s o r t L i s t = $ ( t h i s ) . m e t a d a t a ( ) . s o r t l i s t ; } i f ( c o n f i g . s o r t L i s t . l e n g t h > 0 ) { $ t h i s . t r i g g e r ( " s o r t o n " , [ c o n f i g . s o r t L i s t ] ) ; } a p p l y W i d g e t ( t h i s ) ; } ) ; } ; t h i s . a d d P a r s e r = f u n c t i o n ( p a r s e r ) { v a r   l = p a r s e r s . l e n g t h , a = t r u e ; f o r ( v a r   i = 0 ; i < l ; i + + ) { i f ( p a r s e r s [ i ] . i d . t o L o w e r C a s e ( ) = = p a r s e r . i d . t o L o w e r C a s e ( ) ) { a = f a l s e ; } } i f ( a ) { p a r s e r s . p u s h ( p a r s e r ) ; } ; } ; t h i s . a d d W i d g e t = f u n c t i o n ( w i d g e t ) { w i d g e t s . p u s h ( w i d g e t ) ; } ; t h i s . f o r m a t F l o a t = f u n c t i o n ( s ) { v a r   i = p a r s e F l o a t ( s ) ; r e t u r n ( i s N a N ( i ) ) ? 0 : i ; } ; t h i s . f o r m a t I n t = f u n c t i o n ( s ) { v a r   i = p a r s e I n t ( s ) ; r e t u r n ( i s N a N ( i ) ) ? 0 : i ; } ; t h i s . i s D i g i t = f u n c t i o n ( s , c o n f i g ) { v a r   D E C I M A L = ' \ \ ' + c o n f i g . d e c i m a l ; v a r   e x p = ' / ( ^ [ + ] ? 0 ( ' + D E C I M A L + ' 0 + ) ? $ ) | ( ^ ( [ - + ] ? [ 1 - 9 ] [ 0 - 9 ] * ) $ ) | ( ^ ( [ - + ] ? ( ( 0 ? | [ 1 - 9 ] [ 0 - 9 ] * ) ' + D E C I M A L + ' ( 0 * [ 1 - 9 ] [ 0 - 9 ] * ) ) ) $ ) | ( ^ [ - + ] ? [ 1 - 9 ] + [ 0 - 9 ] * ' + D E C I M A L + ' 0 + $ ) / ' ; r e t u r n   R e g E x p ( e x p ) . t e s t ( $ . t r i m ( s ) ) ; } ; t h i s . c l e a r T a b l e B o d y = f u n c t i o n ( t a b l e ) { i f ( $ . b r o w s e r . m s i e ) { f u n c t i o n   e m p t y ( ) { w h i l e ( t h i s . f i r s t C h i l d ) t h i s . r e m o v e C h i l d ( t h i s . f i r s t C h i l d ) ; } e m p t y . a p p l y ( t a b l e . t B o d i e s [ 0 ] ) ; } e l s e { t a b l e . t B o d i e s [ 0 ] . i n n e r H T M L = " " ; } } ; } } ) ; $ . f n . e x t e n d ( { t a b l e s o r t e r : $ . t a b l e s o r t e r . c o n s t r u c t } ) ; v a r   t s = $ . t a b l e s o r t e r ; t s . a d d P a r s e r ( { i d : " t e x t " , i s : f u n c t i o n ( s ) { r e t u r n   t r u e ; } , f o r m a t : f u n c t i o n ( s ) { r e t u r n   $ . t r i m ( s . t o L o w e r C a s e ( ) ) ; } , t y p e : " t e x t " } ) ; t s . a d d P a r s e r ( { i d : " d i g i t " , i s : f u n c t i o n ( s , t a b l e ) { v a r   c = t a b l e . c o n f i g ; r e t u r n   $ . t a b l e s o r t e r . i s D i g i t ( s , c ) ; } , f o r m a t : f u n c t i o n ( s ) { r e t u r n   $ . t a b l e s o r t e r . f o r m a t F l o a t ( s ) ; } , t y p e : " n u m e r i c " } ) ; t s . a d d P a r s e r ( { i d : " c u r r e n c y " , i s : f u n c t i o n ( s ) { r e t u r n / ^ [ ýÿ$ ýÿýÿýÿ? . ] / . t e s t ( s ) ; } , f o r m a t : f u n c t i o n ( s ) { r e t u r n   $ . t a b l e s o r t e r . f o r m a t F l o a t ( s . r e p l a c e ( n e w   R e g E x p ( / [ ^ 0 - 9 . ] / g ) , " " ) ) ; } , t y p e : " n u m e r i c " } ) ; t s . a d d P a r s e r ( { i d : " i p A d d r e s s " , i s : f u n c t i o n ( s ) { r e t u r n / ^ \ d { 2 , 3 } [ \ . ] \ d { 2 , 3 } [ \ . ] \ d { 2 , 3 } [ \ . ] \ d { 2 , 3 } $ / . t e s t ( s ) ; } , f o r m a t : f u n c t i o n ( s ) { v a r   a = s . s p l i t ( " . " ) , r = " " , l = a . l e n g t h ; f o r ( v a r   i = 0 ; i < l ; i + + ) { v a r   i t e m = a [ i ] ; i f ( i t e m . l e n g t h = = 2 ) { r + = " 0 " + i t e m ; } e l s e { r + = i t e m ; } } r e t u r n   $ . t a b l e s o r t e r . f o r m a t F l o a t ( r ) ; } , t y p e : " n u m e r i c " } ) ; t s . a d d P a r s e r ( { i d : " u r l " , i s : f u n c t i o n ( s ) { r e t u r n / ^ ( h t t p s ? | f t p | f i l e ) : \ / \ / $ / . t e s t ( s ) ; } , f o r m a t : f u n c t i o n ( s ) { r e t u r n   j Q u e r y . t r i m ( s . r e p l a c e ( n e w   R e g E x p ( / ( h t t p s ? | f t p | f i l e ) : \ / \ / / ) , ' ' ) ) ; } , t y p e : " t e x t " } ) ; t s . a d d P a r s e r ( { i d : " i s o D a t e " , i s : f u n c t i o n ( s ) { r e t u r n / ^ \ d { 4 } [ \ / - ] \ d { 1 , 2 } [ \ / - ] \ d { 1 , 2 } $ / . t e s t ( s ) ; } , f o r m a t : f u n c t i o n ( s ) { r e t u r n   $ . t a b l e s o r t e r . f o r m a t F l o a t ( ( s ! = " " ) ? n e w   D a t e ( s . r e p l a c e ( n e w   R e g E x p ( / - / g ) , " / " ) ) . g e t T i m e ( ) : " 0 " ) ; } , t y p e : " n u m e r i c " } ) ; t s . a d d P a r s e r ( { i d : " p e r c e n t " , i s : f u n c t i o n ( s ) { r e t u r n / \ % $ / . t e s t ( $ . t r i m ( s ) ) ; } , f o r m a t : f u n c t i o n ( s ) { r e t u r n   $ . t a b l e s o r t e r . f o r m a t F l o a t ( s . r e p l a c e ( n e w   R e g E x p ( / % / g ) , " " ) ) ; } , t y p e : " n u m e r i c " } ) ; t s . a d d P a r s e r ( { i d : " u s L o n g D a t e " , i s : f u n c t i o n ( s ) { r e t u r n   s . m a t c h ( n e w   R e g E x p ( / ^ [ A - Z a - z ] { 3 , 1 0 } \ . ?   [ 0 - 9 ] { 1 , 2 } ,   ( [ 0 - 9 ] { 4 } | ' ? [ 0 - 9 ] { 2 } )   ( ( [ 0 - 2 ] ? [ 0 - 9 ] : [ 0 - 5 ] [ 0 - 9 ] ) | ( [ 0 - 1 ] ? [ 0 - 9 ] : [ 0 - 5 ] [ 0 - 9 ] \ s ( A M | P M ) ) ) $ / ) ) ; } , f o r m a t : f u n c t i o n ( s ) { r e t u r n   $ . t a b l e s o r t e r . f o r m a t F l o a t ( n e w   D a t e ( s ) . g e t T i m e ( ) ) ; } , t y p e : " n u m e r i c " } ) ; t s . a d d P a r s e r ( { i d : " s h o r t D a t e " , i s : f u n c t i o n ( s ) { r e t u r n / \ d { 1 , 2 } [ \ / \ - ] \ d { 1 , 2 } [ \ / \ - ] \ d { 2 , 4 } / . t e s t ( s ) ; } , f o r m a t : f u n c t i o n ( s , t a b l e ) { v a r   c = t a b l e . c o n f i g ; s = s . r e p l a c e ( / \ - / g , " / " ) ; i f ( c . d a t e F o r m a t = = " u s " ) { s = s . r e p l a c e ( / ( \ d { 1 , 2 } ) [ \ / \ - ] ( \ d { 1 , 2 } ) [ \ / \ - ] ( \ d { 4 } ) / , " $ 3 / $ 1 / $ 2 " ) ; } e l s e   i f ( c . d a t e F o r m a t = = " u k " ) { s = s . r e p l a c e ( / ( \ d { 1 , 2 } ) [ \ / \ - ] ( \ d { 1 , 2 } ) [ \ / \ - ] ( \ d { 4 } ) / , " $ 3 / $ 2 / $ 1 " ) ; } e l s e   i f ( c . d a t e F o r m a t = = " d d / m m / y y " | | c . d a t e F o r m a t = = " d d - m m - y y " ) { s = s . r e p l a c e ( / ( \ d { 1 , 2 } ) [ \ / \ - ] ( \ d { 1 , 2 } ) [ \ / \ - ] ( \ d { 2 } ) / , " $ 1 / $ 2 / $ 3 " ) ; } r e t u r n   $ . t a b l e s o r t e r . f o r m a t F l o a t ( n e w   D a t e ( s ) . g e t T i m e ( ) ) ; } , t y p e : " n u m e r i c " } ) ; t s . a d d P a r s e r ( { i d : " t i m e " , i s : f u n c t i o n ( s ) { r e t u r n / ^ ( ( [ 0 - 2 ] ? [ 0 - 9 ] : [ 0 - 5 ] [ 0 - 9 ] ) | ( [ 0 - 1 ] ? [ 0 - 9 ] : [ 0 - 5 ] [ 0 - 9 ] \ s ( a m | p m ) ) ) $ / . t e s t ( s ) ; } , f o r m a t : f u n c t i o n ( s ) { r e t u r n   $ . t a b l e s o r t e r . f o r m a t F l o a t ( n e w   D a t e ( " 2 0 0 0 / 0 1 / 0 1   " + s ) . g e t T i m e ( ) ) ; } , t y p e : " n u m e r i c " } ) ; t s . a d d P a r s e r ( { i d : " m e t a d a t a " , i s : f u n c t i o n ( s ) { r e t u r n   f a l s e ; } , f o r m a t : f u n c t i o n ( s , t a b l e , c e l l ) { v a r   c = t a b l e . c o n f i g , p = ( ! c . p a r s e r M e t a d a t a N a m e ) ? ' s o r t V a l u e ' : c . p a r s e r M e t a d a t a N a m e ; r e t u r n   $ ( c e l l ) . m e t a d a t a ( ) [ p ] ; } , t y p e : " n u m e r i c " } ) ; t s . a d d W i d g e t ( { i d : " z e b r a " , f o r m a t : f u n c t i o n ( t a b l e ) { i f ( t a b l e . c o n f i g . d e b u g ) { v a r   t i m e = n e w   D a t e ( ) ; } $ ( " t r : v i s i b l e " , t a b l e . t B o d i e s [ 0 ] ) . f i l t e r ( ' : e v e n ' ) . r e m o v e C l a s s ( t a b l e . c o n f i g . w i d g e t Z e b r a . c s s [ 1 ] ) . a d d C l a s s ( t a b l e . c o n f i g . w i d g e t Z e b r a . c s s [ 0 ] ) . e n d ( ) . f i l t e r ( ' : o d d ' ) . r e m o v e C l a s s ( t a b l e . c o n f i g . w i d g e t Z e b r a . c s s [ 0 ] ) . a d d C l a s s ( t a b l e . c o n f i g . w i d g e t Z e b r a . c s s [ 1 ] ) ; i f ( t a b l e . c o n f i g . d e b u g ) { $ . t a b l e s o r t e r . b e n c h m a r k ( " A p p l y i n g   Z e b r a   w i d g e t " , t i m e ) ; } } } ) ; } ) ( j Q u e r y ) ; 
