@@ -2,19 +2,21 @@ function updateSettingsPage(){
22
33 let themesEl = $ ( ".pageSettings .section .themes" ) . empty ( ) ;
44 themesList . forEach ( theme => {
5- if ( config . theme == 'theme' ) {
6- themesEl . append ( `<div class="theme active" theme='${ theme } '>${ theme . replace ( '_' , ' ' ) } </div>` ) ;
7- } else {
8- themesEl . append ( `<div class="theme" theme='${ theme } '>${ theme . replace ( '_' , ' ' ) } </div>` ) ;
9- }
5+ themesEl . append ( `<div class="theme" theme='${ theme } '>${ theme . replace ( '_' , ' ' ) } </div>` ) ;
6+ } )
7+
8+ let langEl = $ ( ".pageSettings .section .languages" ) . empty ( ) ;
9+ Object . keys ( words ) . forEach ( language => {
10+ langEl . append ( `<div class="language" language='${ language } '>${ language . replace ( '_' , ' ' ) } </div>` ) ;
1011 } )
1112
1213 setSettingsButton ( 'smoothCaret' , config . smoothCaret ) ;
1314 setSettingsButton ( 'quickTab' , config . quickTab ) ;
1415 setSettingsButton ( 'liveWpm' , config . showLiveWpm ) ;
1516 setSettingsButton ( 'keyTips' , config . showKeyTips ) ;
16- setActiveThemeButton ( config . theme ) ;
1717
18+ setActiveThemeButton ( ) ;
19+ setActiveLanguageButton ( ) ;
1820
1921 if ( config . showKeyTips ) {
2022 $ ( ".pageSettings .tip" ) . removeClass ( 'hidden' ) ;
@@ -25,9 +27,14 @@ function updateSettingsPage(){
2527
2628}
2729
28- function setActiveThemeButton ( theme ) {
29- $ ( ".pageSettings .themes .theme" ) . removeClass ( 'active' ) ;
30- $ ( ".pageSettings .themes .theme[theme=" + theme + "]" ) . addClass ( 'active' ) ;
30+ function setActiveThemeButton ( ) {
31+ $ ( `.pageSettings .section .themes .theme` ) . removeClass ( 'active' ) ;
32+ $ ( `.pageSettings .section .themes .theme[theme=${ config . theme } ]` ) . addClass ( 'active' ) ;
33+ }
34+
35+ function setActiveLanguageButton ( ) {
36+ $ ( `.pageSettings .section .languages .language` ) . removeClass ( 'active' ) ;
37+ $ ( `.pageSettings .section .languages .language[language=${ config . language } ]` ) . addClass ( 'active' ) ;
3138}
3239
3340function setSettingsButton ( buttonSection , tf ) {
@@ -99,6 +106,7 @@ $(".pageSettings .section.keyTips .buttons .button.off").click(e => {
99106 }
100107} )
101108
109+ //themes
102110$ ( document ) . on ( "mouseover" , ".pageSettings .section .themes .theme" , ( e ) => {
103111 let theme = $ ( e . currentTarget ) . attr ( 'theme' ) ;
104112 previewTheme ( theme ) ;
@@ -107,8 +115,17 @@ $(document).on("mouseover",".pageSettings .section .themes .theme", (e) => {
107115$ ( document ) . on ( "click" , ".pageSettings .section .themes .theme" , ( e ) => {
108116 let theme = $ ( e . currentTarget ) . attr ( 'theme' ) ;
109117 setTheme ( theme ) ;
118+ setActiveThemeButton ( ) ;
110119} )
111120
112121$ ( document ) . on ( "mouseleave" , ".pageSettings .section .themes" , ( e ) => {
113122 setTheme ( config . theme ) ;
123+ } )
124+
125+ //languages
126+ $ ( document ) . on ( "click" , ".pageSettings .section .languages .language" , ( e ) => {
127+ let language = $ ( e . currentTarget ) . attr ( 'language' ) ;
128+ changeLanguage ( language ) ;
129+ restartTest ( ) ;
130+ setActiveLanguageButton ( ) ;
114131} )
0 commit comments