77 < span id ="hand-selected "> {{ e.total }}</ span >
88 < img alt ="arrow_down " src ="/assets/img/arrow_down.png " style ="aspect-ratio: 1 / 1; height: 1.6em; ">
99 </ label >
10- < div id =" hand- select-options " class =" select-options ">
11- < span class ="select-option "> {{ e.total }}</ span >
10+ < div class =" select-options " id =" hand- select-options ">
11+ < span class ="select-option choose "> {{ e.total }}</ span >
1212 < span class ="select-option "> {{ e.preferred }}</ span >
1313 < span class ="select-option "> {{ e.hf_format | replace: '%h%', e.left | replace: '%f%', e.hand }}</ span >
1414 < span class ="select-option "> {{ e.hf_format | replace: '%h%', e.right | replace: '%f%', e.hand }}</ span >
2020 < span id ="finger-selected "> {{ e.all_button }}</ span >
2121 < img alt ="arrow_down " src ="/assets/img/arrow_down.png " style ="aspect-ratio: 1 / 1; height: 1.6em; ">
2222 </ label >
23- < div id =" finger- select-options " class =" select-options ">
24- < span class ="select-option "> {{ e.all_button }}</ span >
23+ < div class =" select-options " id =" finger- select-options ">
24+ < span class ="select-option choose "> {{ e.all_button }}</ span >
2525 < span class ="select-option "> {{ e.thumb }}</ span >
2626 < span class ="select-option "> {{ e.index }}</ span >
2727 < span class ="select-option "> {{ e.middle }}</ span >
7878 const selectionText = document . getElementById ( 'selection-text' ) ;
7979 const selectionIcon = document . querySelector ( '#selection-badge .selection-icon' ) ;
8080 const fingerContext = document . getElementById ( 'finger-context' ) ;
81+ const handOptions = document . querySelectorAll ( '#hand-select-options .select-option' ) ;
82+ console . log ( handOptions )
83+ const fingerOptions = document . querySelectorAll ( '#finger-select-options .select-option' ) ;
84+
85+ let allFingerOption = fingerOptions [ 0 ] ;
8186
8287 const FACES = [ 'R' , 'B' , 'G' , 'W' , 'Y' ] ;
8388 const ALL_FINGERS = [ 'LT' , 'LI' , 'LM' , 'LR' , 'LL' , 'RT' , 'RI' , 'RM' , 'RR' , 'RL' ] ;
157162 const preferredFingers = preferenceAggregate . tiedFingers [ face ] [ i ] ;
158163 preferredFingers . forEach ( function ( f ) {
159164 const fData = window . perFingerReachability [ f ] ;
165+ allFingerOption . classList . add ( 'choose' ) ;
160166 if ( fData ) {
161167 let s = 0 ;
162168 fData . forEach ( function ( p ) {
197203 }
198204 }
199205
200- function handleFirstSelect ( value ) {
201- let selectValue = handleCustomSelect ( value ) ;
202- if ( selectValue === "total" ) {
203- if ( fingerSelect . classList . contains ( 'active' ) ) {
204- fingerSelect . classList . remove ( 'active' ) ;
205- fingerCheckbox . checked = false ;
206- fingerLabel . textContent = '{{ e.all_button }}'
207- }
206+ function handleFirstSelect ( e ) {
207+ if ( e === 'start' ) {
208208 updateSelection ( "total" ) ;
209- handLabel . textContent = value ;
210- } else if ( selectValue === "preferred" ) {
211- if ( fingerSelect . classList . contains ( 'active' ) ) {
212- fingerSelect . classList . remove ( 'active' ) ;
213- fingerCheckbox . checked = false ;
214- fingerLabel . textContent = '{{ e.all_button }}'
215- }
216- handleBestFinger ( ) ;
217- handLabel . textContent = value ;
218209 } else {
219- fingerSelect . classList . add ( 'active' )
220- if ( selectValue === 'L' ) {
221- handleHandAll ( 'left' )
222- handLabel . textContent = value ;
210+ let selectValue = handleCustomSelect ( e . textContent ) ;
211+ debugger ;
212+ if ( selectValue === "total" ) {
213+ if ( fingerSelect . classList . contains ( 'active' ) ) {
214+ fingerSelect . classList . remove ( 'active' ) ;
215+ fingerCheckbox . checked = false ;
216+ fingerLabel . textContent = '{{ e.all_button }}'
217+ fingerOptions . forEach ( elem => {
218+ elem . classList . remove ( 'choose' )
219+ } )
220+ allFingerOption . classList . add ( 'choose' ) ;
221+ }
222+ updateSelection ( "total" ) ;
223+ handLabel . textContent = e . textContent ;
224+ handCheckbox . checked = false ;
225+ handOptions . forEach ( elem => {
226+ elem . classList . remove ( 'choose' )
227+ } )
228+ e . classList . add ( 'choose' ) ;
229+ } else if ( selectValue === "preferred" ) {
230+ if ( fingerSelect . classList . contains ( 'active' ) ) {
231+ fingerSelect . classList . remove ( 'active' ) ;
232+ fingerCheckbox . checked = false ;
233+ fingerLabel . textContent = '{{ e.all_button }}'
234+ fingerOptions . forEach ( elem => {
235+ elem . classList . remove ( 'choose' )
236+ } )
237+ allFingerOption . classList . add ( 'choose' ) ;
238+ }
239+ handleBestFinger ( ) ;
240+ handLabel . textContent = e . textContent ;
241+ handCheckbox . checked = false ;
242+ handOptions . forEach ( elem => {
243+ elem . classList . remove ( 'choose' )
244+ } )
245+ e . classList . add ( 'choose' ) ;
223246 } else {
224- handleHandAll ( 'right' )
225- handLabel . textContent = value ;
247+ fingerSelect . classList . add ( 'active' )
248+ if ( selectValue === 'L' ) {
249+ handleHandAll ( 'left' )
250+ handLabel . textContent = e . textContent ;
251+ handCheckbox . checked = false ;
252+ handOptions . forEach ( elem => {
253+ elem . classList . remove ( 'choose' )
254+ } )
255+ e . classList . add ( 'choose' ) ;
256+ } else {
257+ handleHandAll ( 'right' )
258+ handLabel . textContent = e . textContent ;
259+ handCheckbox . checked = false ;
260+ handOptions . forEach ( elem => {
261+ elem . classList . remove ( 'choose' )
262+ } )
263+ e . classList . add ( 'choose' ) ;
264+ }
226265 }
227266 }
228267 }
229268
230- function handleSecondSelect ( value ) {
231- let selectValue = handleCustomSelect ( value ) ;
269+ function handleSecondSelect ( e ) {
270+ let selectValue = handleCustomSelect ( e . textContent ) ;
232271 switch ( selectValue ) {
233272 case "H" :
234273 if ( handleCustomSelect ( handLabel . textContent ) === 'L' ) {
235274 handleHandAll ( 'left' )
236- fingerLabel . textContent = value ;
275+ fingerLabel . textContent = e . textContent ;
276+ fingerCheckbox . checked = false ;
277+ fingerOptions . forEach ( elem => {
278+ elem . classList . remove ( 'choose' )
279+ } )
280+ e . classList . add ( 'choose' ) ;
237281 } else {
238282 handleHandAll ( 'right' )
239- fingerLabel . textContent = value ;
240- } break ;
283+ fingerLabel . textContent = e . textContent ;
284+ fingerCheckbox . checked = false ;
285+ fingerOptions . forEach ( elem => {
286+ elem . classList . remove ( 'choose' )
287+ } )
288+ e . classList . add ( 'choose' ) ;
289+ }
290+ break ;
241291 case "T" :
242292 case "I" :
243293 case "M" :
244294 case "R" :
245295 case "L" :
246296 updateSelection ( handleCustomSelect ( handLabel . textContent ) + selectValue ) ;
247- fingerLabel . textContent = value ;
297+ fingerLabel . textContent = e . textContent ;
298+ fingerCheckbox . checked = false ;
299+ fingerOptions . forEach ( elem => {
300+ elem . classList . remove ( 'choose' )
301+ } )
302+ e . classList . add ( 'choose' ) ;
248303 break ;
249304 }
250305 }
257312 fingerCheckbox . checked = false ;
258313 } )
259314
260- document . querySelectorAll ( '#hand-select-options .select-option' ) . forEach ( elem => {
315+ handOptions . forEach ( elem => {
261316 elem . addEventListener ( 'click' , ( ) => {
262- handleFirstSelect ( elem . textContent ) ;
317+ handleFirstSelect ( elem ) ;
263318 } ) ;
264319 } )
265320
266- document . querySelectorAll ( '#finger-select-options .select-option' ) . forEach ( elem => {
321+ fingerOptions . forEach ( elem => {
267322 elem . addEventListener ( 'click' , ( ) => {
268- handleSecondSelect ( elem . textContent ) ;
323+ handleSecondSelect ( elem ) ;
269324 } ) ;
270325 } )
271326
272- handleFirstSelect ( '{{ e.total }} ' ) ;
327+ handleFirstSelect ( 'start ' ) ;
273328 document . getElementById ( 'model-container' ) . classList . add ( 'active' ) ;
274329 } ) ;
275330</ script >
0 commit comments