File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
10 - Hold Shift and Check Checkboxes Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 104
104
</ div >
105
105
106
106
< script >
107
+ let shiftPressing = 0 ;
108
+ let prevIdx = [ 0 , 0 ] ;
109
+
110
+ window . addEventListener ( 'keydown' , e => {
111
+ if ( e . keyCode === 16 ) {
112
+ shiftPressing = 1 ;
113
+ }
114
+ } ) ;
115
+ window . addEventListener ( 'keyup' , e => {
116
+ if ( e . keyCode === 16 ) {
117
+ shiftPressing = 0 ;
118
+ }
119
+ } ) ;
120
+
121
+ [ ...document . querySelectorAll ( 'input[type="checkbox"]' ) ] . forEach ( ( ele , index ) => {
122
+ ele . addEventListener ( 'change' , function ( e ) {
123
+ if ( this . checked ) {
124
+ prevIdx . shift ( ) ;
125
+ prevIdx . push ( index ) ;
126
+ }
127
+ if ( this . checked && shiftPressing ) {
128
+ [ ...document . querySelectorAll ( 'input[type="checkbox"]' ) ] . forEach ( ( el , idx ) => {
129
+ if ( ( idx <= prevIdx [ 1 ] && idx >= prevIdx [ 0 ] ) || ( idx >= prevIdx [ 1 ] && idx <= prevIdx [ 0 ] ) ) {
130
+ el . checked = true ;
131
+ }
132
+ } )
133
+ }
134
+ } )
135
+ } )
107
136
</ script >
108
137
</ body >
109
138
</ html >
Original file line number Diff line number Diff line change 13
13
7 . [x] ~~ Array Cardio, Day 2~~
14
14
8 . [x] ~~ Fun with HTML5 Canvas~~
15
15
9 . [x] ~~ Dev Tools Domination~~
16
- 10 . [ ] Hold Shift and Check Checkboxes
16
+ 10 . [x] ~~ Hold Shift and Check Checkboxes~~
17
17
11 . [ ] Custom Video Player
18
18
12 . [ ] Key Sequence Detection
19
19
13 . [ ] Slide in on Scroll
You can’t perform that action at this time.
0 commit comments