@@ -10,58 +10,59 @@ import { QuoteLength, QuoteLengthConfig } from "@monkeytype/schemas/configs";
1010import { Mode } from "@monkeytype/schemas/shared" ;
1111import { areUnsortedArraysEqual } from "../utils/arrays" ;
1212import * as ShareTestSettingsPopup from "./share-test-settings" ;
13+ import { qsr } from "../utils/dom" ;
1314
1415function update ( ) : void {
15- const el = $ ( "#mobileTestConfigModal" ) ;
16- el . find ( "button" ) . removeClass ( "active" ) ;
16+ const el = qsr ( "#mobileTestConfigModal" ) ;
17+ el . qs ( "button" ) ? .removeClass ( "active" ) ;
1718
18- el . find ( `.modeGroup button[data-mode='${ Config . mode } ']` ) . addClass ( "active" ) ;
19- el . find ( ".timeGroup" ) . addClass ( "hidden" ) ;
20- el . find ( ".wordsGroup" ) . addClass ( "hidden" ) ;
21- el . find ( ".quoteGroup" ) . addClass ( "hidden" ) ;
22- el . find ( ".customGroup" ) . addClass ( "hidden" ) ;
23- el . find ( `.${ Config . mode } Group` ) . removeClass ( "hidden" ) ;
19+ el . qs ( `.modeGroup button[data-mode='${ Config . mode } ']` ) ? .addClass ( "active" ) ;
20+ el . qs ( ".timeGroup" ) ?. hide ( ) ;
21+ el . qs ( ".wordsGroup" ) ?. hide ( ) ;
22+ el . qs ( ".quoteGroup" ) ?. hide ( ) ;
23+ el . qs ( ".customGroup" ) ?. hide ( ) ;
24+ el . qs ( `.${ Config . mode } Group` ) ?. show ( ) ;
2425
2526 if ( Config . punctuation ) {
26- el . find ( ".punctuation" ) . addClass ( "active" ) ;
27+ el . qs ( ".punctuation" ) ? .addClass ( "active" ) ;
2728 } else {
28- el . find ( ".punctuation" ) . removeClass ( "active" ) ;
29+ el . qs ( ".punctuation" ) ? .removeClass ( "active" ) ;
2930 }
3031
3132 if ( Config . numbers ) {
32- el . find ( ".numbers" ) . addClass ( "active" ) ;
33+ el . qs ( ".numbers" ) ? .addClass ( "active" ) ;
3334 } else {
34- el . find ( ".numbers" ) . removeClass ( "active" ) ;
35+ el . qs ( ".numbers" ) ? .removeClass ( "active" ) ;
3536 }
3637
3738 if ( Config . mode === "time" ) {
38- el . find ( `.timeGroup button[data-time='${ Config . time } ']` ) . addClass ( "active" ) ;
39- el . find ( ".punctuation" ) . removeClass ( "disabled" ) ;
40- el . find ( ".numbers" ) . removeClass ( "disabled" ) ;
39+ el . qs ( `.timeGroup button[data-time='${ Config . time } ']` ) ? .addClass ( "active" ) ;
40+ el . qs ( ".punctuation" ) ?. enable ( ) ;
41+ el . qs ( ".numbers" ) ?. enable ( ) ;
4142 } else if ( Config . mode === "words" ) {
42- el . find ( `.wordsGroup button[data-words='${ Config . words } ']` ) . addClass (
43+ el . qs ( `.wordsGroup button[data-words='${ Config . words } ']` ) ? .addClass (
4344 "active" ,
4445 ) ;
45- el . find ( ".punctuation" ) . removeClass ( "disabled" ) ;
46- el . find ( ".numbers" ) . removeClass ( "disabled" ) ;
46+ el . qs ( ".punctuation" ) ?. enable ( ) ;
47+ el . qs ( ".numbers" ) ?. enable ( ) ;
4748 } else if ( Config . mode === "quote" ) {
4849 if ( areUnsortedArraysEqual ( Config . quoteLength , [ 0 , 1 , 2 , 3 ] ) ) {
49- el . find ( `.quoteGroup button[data-quoteLength='all']` ) . addClass ( "active" ) ;
50+ el . qs ( `.quoteGroup button[data-quoteLength='all']` ) ? .addClass ( "active" ) ;
5051 } else {
5152 for ( const ql of Config . quoteLength ) {
52- el . find ( `.quoteGroup button[data-quoteLength='${ ql } ']` ) . addClass (
53+ el . qs ( `.quoteGroup button[data-quoteLength='${ ql } ']` ) ? .addClass (
5354 "active" ,
5455 ) ;
5556 }
5657 }
57- el . find ( ".punctuation" ) . addClass ( "disabled" ) ;
58- el . find ( ".numbers" ) . addClass ( "disabled" ) ;
58+ el . qs ( ".punctuation" ) ?. disable ( ) ;
59+ el . qs ( ".numbers" ) ?. disable ( ) ;
5960 } else if ( Config . mode === "zen" ) {
60- el . find ( ".punctuation" ) . addClass ( "disabled" ) ;
61- el . find ( ".numbers" ) . addClass ( "disabled" ) ;
61+ el . qs ( ".punctuation" ) ?. disable ( ) ;
62+ el . qs ( ".numbers" ) ?. disable ( ) ;
6263 } else if ( Config . mode === "custom" ) {
63- el . find ( ".punctuation" ) . removeClass ( "disabled" ) ;
64- el . find ( ".numbers" ) . removeClass ( "disabled" ) ;
64+ el . qs ( ".punctuation" ) ?. enable ( ) ;
65+ el . qs ( ".numbers" ) ?. enable ( ) ;
6566 }
6667}
6768
0 commit comments