@@ -25,13 +25,14 @@ function togglePreferences() {
2525 addCheckboxListener ( document . getElementById ( 'pref-adblk' ) , 'adblk' ) ;
2626 if ( preferences . agent . toString ( ) . length > 1 ) {
2727 document . getElementById ( 'pref-useragent' ) . value =
28- preferences . agent || 'Catalyst/{{version}}' ;
28+ preferences . agent || 'Catalyst/{{version}}' ;
2929 } else {
3030 document . getElementById ( 'pref-useragent' ) . value = preferences . agent ;
3131 }
3232 addTextListener ( document . getElementById ( 'pref-useragent' ) , 'agent' ) ;
3333 addCheckboxListener ( document . getElementById ( 'pref-homewidgets' ) , 'homewidgets' ) ;
3434 document . getElementById ( 'pref-homewidgets' ) . checked = preferences . homewidgets ;
35+ addSelectListener ( document . getElementById ( 'pref-theme' ) , 'theme' )
3536 }
3637}
3738
@@ -77,6 +78,13 @@ function addTextListener(element, prefKey) {
7778 } ) ;
7879}
7980
81+ function addSelectListener ( element , prefKey ) {
82+ element . addEventListener ( 'change' , ( ) => {
83+ preferences [ prefKey ] = element . value ;
84+ updatePreferences ( ) ;
85+ } )
86+ }
87+
8088/**
8189 * Updates the preferences in LocalStorage to the new preferences and evaluates the new ones
8290 */
@@ -100,6 +108,15 @@ function evaluatePreferences() {
100108 if ( preferences . adblk ) {
101109 cat . enableAdBlocker ( ) ;
102110 }
111+ if ( preferences . theme ) {
112+ if ( document . getElementsByClassName ( 'theme' ) . length > 0 ) {
113+ cat . unloadTheme ( ) ;
114+ }
115+ if ( preferences . theme == 0 ) {
116+ return ;
117+ }
118+ cat . loadTheme ( preferences . theme )
119+ }
103120}
104121
105122var enginespref = document . querySelector ( '#se' ) ;
0 commit comments