@@ -81,85 +81,85 @@ sorttable = {
8181 if ( ! headrow [ i ] . className . match ( / \b s o r t t a b l e _ n o s o r t \b / ) ) { // skip this col
8282 mtch = headrow [ i ] . className . match ( / \b s o r t t a b l e _ ( [ a - z 0 - 9 ] + ) \b / ) ;
8383 if ( mtch ) { override = mtch [ 1 ] ; }
84- if ( mtch && typeof sorttable [ "sort_" + override ] == 'function' ) {
85- headrow [ i ] . sorttable_sortfunction = sorttable [ "sort_" + override ] ;
86- } else {
87- headrow [ i ] . sorttable_sortfunction = sorttable . guessType ( table , i ) ;
88- }
89- // make it clickable to sort
90- headrow [ i ] . sorttable_columnindex = i ;
91- headrow [ i ] . sorttable_tbody = table . tBodies [ 0 ] ;
92- dean_addEvent ( headrow [ i ] , "click" , function ( e ) {
93-
94- if ( this . className . search ( / \b s o r t t a b l e _ s o r t e d \b / ) != - 1 ) {
95- // if we're already sorted by this column, just
96- // reverse the table, which is quicker
97- sorttable . reverse ( this . sorttable_tbody ) ;
98- this . className = this . className . replace ( 'sorttable_sorted' ,
99- 'sorttable_sorted_reverse' ) ;
100- this . removeChild ( document . getElementById ( 'sorttable_sortfwdind' ) ) ;
101- sortrevind = document . createElement ( 'span' ) ;
102- sortrevind . id = "sorttable_sortrevind" ;
103- sortrevind . innerHTML = stIsIE ? ' <font face="webdings">5</font>' : ' ▴' ;
104- this . appendChild ( sortrevind ) ;
105- return ;
84+ if ( mtch && typeof sorttable [ "sort_" + override ] == 'function' ) {
85+ headrow [ i ] . sorttable_sortfunction = sorttable [ "sort_" + override ] ;
86+ } else {
87+ headrow [ i ] . sorttable_sortfunction = sorttable . guessType ( table , i ) ;
10688 }
107- if ( this . className . search ( / \b s o r t t a b l e _ s o r t e d _ r e v e r s e \b / ) != - 1 ) {
108- // if we're already sorted by this column in reverse, just
109- // re-reverse the table, which is quicker
110- sorttable . reverse ( this . sorttable_tbody ) ;
111- this . className = this . className . replace ( 'sorttable_sorted_reverse' ,
89+ // make it clickable to sort
90+ headrow [ i ] . sorttable_columnindex = i ;
91+ headrow [ i ] . sorttable_tbody = table . tBodies [ 0 ] ;
92+ dean_addEvent ( headrow [ i ] , "click" , function ( e ) {
93+
94+ if ( this . className . search ( / \b s o r t t a b l e _ s o r t e d \b / ) != - 1 ) {
95+ // if we're already sorted by this column, just
96+ // reverse the table, which is quicker
97+ sorttable . reverse ( this . sorttable_tbody ) ;
98+ this . className = this . className . replace ( 'sorttable_sorted' ,
99+ 'sorttable_sorted_reverse' ) ;
100+ this . removeChild ( document . getElementById ( 'sorttable_sortfwdind' ) ) ;
101+ sortrevind = document . createElement ( 'span' ) ;
102+ sortrevind . id = "sorttable_sortrevind" ;
103+ sortrevind . innerHTML = stIsIE ? ' <font face="webdings">5</font>' : ' ▴' ;
104+ this . appendChild ( sortrevind ) ;
105+ return ;
106+ }
107+ if ( this . className . search ( / \b s o r t t a b l e _ s o r t e d _ r e v e r s e \b / ) != - 1 ) {
108+ // if we're already sorted by this column in reverse, just
109+ // re-reverse the table, which is quicker
110+ sorttable . reverse ( this . sorttable_tbody ) ;
111+ this . className = this . className . replace ( 'sorttable_sorted_reverse' ,
112112 'sorttable_sorted' ) ;
113- this . removeChild ( document . getElementById ( 'sorttable_sortrevind' ) ) ;
113+ this . removeChild ( document . getElementById ( 'sorttable_sortrevind' ) ) ;
114+ sortfwdind = document . createElement ( 'span' ) ;
115+ sortfwdind . id = "sorttable_sortfwdind" ;
116+ sortfwdind . innerHTML = stIsIE ? ' <font face="webdings">6</font>' : ' ▾' ;
117+ this . appendChild ( sortfwdind ) ;
118+ return ;
119+ }
120+
121+ // remove sorttable_sorted classes
122+ theadrow = this . parentNode ;
123+ forEach ( theadrow . childNodes , function ( cell ) {
124+ if ( cell . nodeType == 1 ) { // an element
125+ cell . className = cell . className . replace ( 'sorttable_sorted_reverse' , '' ) ;
126+ cell . className = cell . className . replace ( 'sorttable_sorted' , '' ) ;
127+ }
128+ } ) ;
129+ sortfwdind = document . getElementById ( 'sorttable_sortfwdind' ) ;
130+ if ( sortfwdind ) { sortfwdind . parentNode . removeChild ( sortfwdind ) ; }
131+ sortrevind = document . getElementById ( 'sorttable_sortrevind' ) ;
132+ if ( sortrevind ) { sortrevind . parentNode . removeChild ( sortrevind ) ; }
133+
134+ this . className += ' sorttable_sorted' ;
114135 sortfwdind = document . createElement ( 'span' ) ;
115136 sortfwdind . id = "sorttable_sortfwdind" ;
116137 sortfwdind . innerHTML = stIsIE ? ' <font face="webdings">6</font>' : ' ▾' ;
117138 this . appendChild ( sortfwdind ) ;
118- return ;
119- }
120139
121- // remove sorttable_sorted classes
122- theadrow = this . parentNode ;
123- forEach ( theadrow . childNodes , function ( cell ) {
124- if ( cell . nodeType == 1 ) { // an element
125- cell . className = cell . className . replace ( 'sorttable_sorted_reverse' , '' ) ;
126- cell . className = cell . className . replace ( 'sorttable_sorted' , '' ) ;
140+ // build an array to sort. This is a Schwartzian transform thing,
141+ // i.e., we "decorate" each row with the actual sort key,
142+ // sort based on the sort keys, and then put the rows back in order
143+ // which is a lot faster because you only do getInnerText once per row
144+ row_array = [ ] ;
145+ col = this . sorttable_columnindex ;
146+ rows = this . sorttable_tbody . rows ;
147+ for ( var j = 0 ; j < rows . length ; j ++ ) {
148+ row_array [ row_array . length ] = [ sorttable . getInnerText ( rows [ j ] . cells [ col ] ) , rows [ j ] ] ;
127149 }
128- } ) ;
129- sortfwdind = document . getElementById ( 'sorttable_sortfwdind' ) ;
130- if ( sortfwdind ) { sortfwdind . parentNode . removeChild ( sortfwdind ) ; }
131- sortrevind = document . getElementById ( 'sorttable_sortrevind' ) ;
132- if ( sortrevind ) { sortrevind . parentNode . removeChild ( sortrevind ) ; }
133-
134- this . className += ' sorttable_sorted' ;
135- sortfwdind = document . createElement ( 'span' ) ;
136- sortfwdind . id = "sorttable_sortfwdind" ;
137- sortfwdind . innerHTML = stIsIE ? ' <font face="webdings">6</font>' : ' ▾' ;
138- this . appendChild ( sortfwdind ) ;
139-
140- // build an array to sort. This is a Schwartzian transform thing,
141- // i.e., we "decorate" each row with the actual sort key,
142- // sort based on the sort keys, and then put the rows back in order
143- // which is a lot faster because you only do getInnerText once per row
144- row_array = [ ] ;
145- col = this . sorttable_columnindex ;
146- rows = this . sorttable_tbody . rows ;
147- for ( var j = 0 ; j < rows . length ; j ++ ) {
148- row_array [ row_array . length ] = [ sorttable . getInnerText ( rows [ j ] . cells [ col ] ) , rows [ j ] ] ;
149- }
150- /* If you want a stable sort, uncomment the following line */
151- //sorttable.shaker_sort(row_array, this.sorttable_sortfunction);
152- /* and comment out this one */
153- row_array . sort ( this . sorttable_sortfunction ) ;
150+ /* If you want a stable sort, uncomment the following line */
151+ //sorttable.shaker_sort(row_array, this.sorttable_sortfunction);
152+ /* and comment out this one */
153+ row_array . sort ( this . sorttable_sortfunction ) ;
154154
155- tb = this . sorttable_tbody ;
156- for ( var j = 0 ; j < row_array . length ; j ++ ) {
157- tb . appendChild ( row_array [ j ] [ 1 ] ) ;
158- }
155+ tb = this . sorttable_tbody ;
156+ for ( var j = 0 ; j < row_array . length ; j ++ ) {
157+ tb . appendChild ( row_array [ j ] [ 1 ] ) ;
158+ }
159159
160- delete row_array ;
161- } ) ;
162- }
160+ delete row_array ;
161+ } ) ;
162+ }
163163 }
164164 } ,
165165
0 commit comments