@@ -122,6 +122,32 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
122
122
}
123
123
}
124
124
125
+ function sortByRuntime ( tableRows , columnData ) {
126
+ for ( let [ i , tr ] of tableRows . entries ( ) ) {
127
+ const regexMinutesAndSeconds = / ^ ( \d + m ) \s ? ( \d + s ) $ / i;
128
+ let columnOfTd = tr
129
+ . querySelectorAll ( "td" )
130
+ . item ( columnIndex ) . textContent ;
131
+ let match = columnOfTd . match ( regexMinutesAndSeconds ) ;
132
+ let minutesInSeconds ,
133
+ seconds ,
134
+ timeinSeconds = [ 0 , 0 , 0 ] ;
135
+ if ( match ) {
136
+ const regexMinutes = match [ 1 ] ;
137
+ if ( regexMinutes ) {
138
+ minutesInSeconds = Number ( regexMinutes . replace ( "m" , "" ) ) * 60 ;
139
+ }
140
+ const regexSeconds = match [ 2 ] ;
141
+ if ( regexSeconds ) {
142
+ seconds = Number ( regexSeconds . replace ( "s" , "" ) ) ;
143
+ }
144
+ timeinSeconds = minutesInSeconds + seconds ;
145
+ }
146
+ columnData . push ( `${ timeinSeconds } #${ i } ` ) ;
147
+ columnIndexAndTableRow [ columnData [ i ] ] = tr . innerHTML ;
148
+ }
149
+ }
150
+
125
151
let [ timesClickedColumn , columnIndexesClicked ] = [ 0 , [ ] ] ;
126
152
127
153
function rememberSort ( timesClickedColumn , columnIndexesClicked ) {
@@ -152,6 +178,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
152
178
tableRows,
153
179
columnData,
154
180
isFileSize,
181
+ isTimeSort,
155
182
isDataAttribute,
156
183
colSpanData,
157
184
colSpanSum,
@@ -171,7 +198,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
171
198
if ( isFileSize ) {
172
199
fileSizeColumnTextAndRow [ columnData [ i ] ] = tr . innerHTML ;
173
200
}
174
- if ( ! isFileSize && ! isDataAttribute ) {
201
+ if ( ! isFileSize && ! isDataAttribute && ! isTimeSort ) {
175
202
columnData . push ( `${ tdTextContent } #${ i } ` ) ;
176
203
columnIndexAndTableRow [ `${ tdTextContent } #${ i } ` ] = tr . innerHTML ;
177
204
}
@@ -307,6 +334,11 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
307
334
sortFileSize ( visibleTableRows , columnData ) ;
308
335
}
309
336
337
+ const isTimeSort = th . classList . contains ( "runtime-sort" ) ;
338
+ if ( isTimeSort ) {
339
+ sortByRuntime ( visibleTableRows , columnData ) ;
340
+ }
341
+
310
342
const isRememberSort = sortableTable . classList . contains ( "remember-sort" ) ;
311
343
if ( ! isRememberSort ) {
312
344
rememberSort ( timesClickedColumn , columnIndexesClicked ) ;
@@ -320,6 +352,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
320
352
columnData,
321
353
isFileSize,
322
354
isDataAttribute,
355
+ isTimeSort,
323
356
colSpanData,
324
357
colSpanSum,
325
358
} ;
0 commit comments