@@ -10,10 +10,10 @@ function* _random(n) {
10
10
}
11
11
}
12
12
const data = [ ] , tbody = document . getElementsByTagName ( 'tbody' ) [ 0 ] ;
13
- let index = 1 , i , lbl , selected , temp ;
13
+ let index = 1 , i , lbl , selected ;
14
14
15
- function create ( e , n = 1000 ) { if ( data . length ) clear ( e ) ; append ( e , n ) ; }
16
- function append ( e , n = 1000 ) {
15
+ function create ( n = 1000 ) { if ( data . length ) clear ( ) ; append ( n ) ; }
16
+ function append ( n = 1000 ) {
17
17
const [ r1 , r2 , r3 ] = _random ( n ) ;
18
18
const itemTemplate = document . getElementById ( 'itemTemplate' ) . content . firstElementChild ;
19
19
const itemId = itemTemplate . firstElementChild . firstChild , itemLabel = itemTemplate . querySelector ( 'a.lbl' ) . firstChild ;
@@ -23,16 +23,16 @@ function append(e, n = 1000) {
23
23
tbody . appendChild ( itemTemplate . cloneNode ( true ) ) ;
24
24
}
25
25
}
26
- function update ( e ) {
26
+ function update ( ) {
27
27
const labels = tbody . querySelectorAll ( 'a.lbl' ) , length = labels . length ;
28
28
for ( i = 0 ; i < length ; i += 10 ) labels [ i ] . firstChild . nodeValue = data [ i ] += ' !!!' ;
29
29
}
30
- function clear ( e ) { data . length = 0 ; tbody . textContent = '' }
30
+ function clear ( ) { data . length = 0 ; tbody . textContent = '' }
31
31
32
- function swap ( e ) {
33
- if ( data . length < 999 ) return ;
32
+ function swap ( ) {
33
+ if ( data . length < 999 ) return ; let temp ;
34
34
[ data [ 1 ] , data [ 998 ] ] = [ data [ 998 ] , data [ 1 ] ] ;
35
- tbody . replaceChild ( tbody . children [ 1 ] , ( temp = tbody . children [ 998 ] ) ) ;
35
+ tbody . insertBefore ( tbody . children [ 1 ] , ( temp = tbody . children [ 998 ] ) ) ;
36
36
tbody . insertBefore ( temp , tbody . children [ 1 ] ) ;
37
37
}
38
38
tbody . onclick = ( e ) => {
@@ -49,6 +49,6 @@ tbody.onclick = (e) => {
49
49
}
50
50
}
51
51
for ( let [ key , fn ] of Object . entries ( {
52
- run : create , runlots : ( e ) => create ( e , 10000 ) ,
52
+ run : create , runlots : ( ) => create ( 10000 ) ,
53
53
add : append , update, clear, swaprows : swap
54
- } ) ) document . getElementById ( key ) . onclick = ( e ) => { e . stopPropagation ( ) ; fn ( e ) }
54
+ } ) ) document . getElementById ( key ) . onclick = ( e ) => { e . stopPropagation ( ) ; fn ( ) }
0 commit comments