File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed
Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -147,11 +147,11 @@ button {
147147 float : right;
148148}
149149
150- .watch-list li : nth-last-child ( 2 ) {
150+ .top_2 {
151151 color : # 72bc59 ;
152152}
153153
154- .watch-list li : nth-last-child ( 1 ) {
154+ .top_1 {
155155 color : # fd455f ;
156156}
157157
Original file line number Diff line number Diff line change @@ -153,15 +153,22 @@ Stopwatch.prototype = {
153153 time = [ ] ,
154154 index = 0 ;
155155 length = list . length ;
156-
156+ var row = this . getTopRow ( ) ;
157157 if ( this . status === 'START' ) {
158158 time = this . formatData ( ) ;
159159 li = '<li>计次' + ( length + 1 ) + '<i>' + time [ 0 ] + ':' + time [ 1 ] + '.' + time [ 2 ] + '</i></li>' ;
160160 index ++ ;
161161 }
162162 while ( length -- > 0 ) {
163163 time = this . formatData ( list [ length ] ) ;
164- li += '<li>计次' + ( 1 + length ) + '<i>' + time [ 0 ] + ':' + time [ 1 ] + '.' + time [ 2 ] + '</i></li>' ;
164+ var name = '' ;
165+ for ( var k = 0 ; k < row . length ; k ++ ) {
166+ if ( row [ k ] === list [ length ] ) {
167+ name = ' class="top_' + ( k + 1 ) + '"' ;
168+ break ;
169+ }
170+ }
171+ li += '<li' + name + '>计次' + ( 1 + length ) + '<i>' + time [ 0 ] + ':' + time [ 1 ] + '.' + time [ 2 ] + '</i></li>' ;
165172 index ++ ;
166173 }
167174
@@ -191,16 +198,16 @@ Stopwatch.prototype = {
191198 } ,
192199
193200 /**
194- * 找出前N名
201+ * 秒表记录排序
195202 * @param int n = 3
196203 */
197204 getTopRow :function ( n ) {
198- n = n || 3 ;
199205 var arr = this . recordList . slice ( ) ;
206+ n = n || 3 ;
200207 arr . sort ( function ( a , b ) {
201- return b - a ;
208+ return b - a
202209 } ) ;
203- return arr ;
210+ return arr . slice ( 0 , n ) ;
204211 }
205212}
206213
You can’t perform that action at this time.
0 commit comments