@@ -118,6 +118,11 @@ function exportConfig() {
118
118
} ) ;
119
119
}
120
120
121
+ function filterMethodSelect ( event ) {
122
+ config . filterMethod = document . getElementById ( 'filterMethodSelect' ) . selectedIndex ;
123
+ saveOptions ( event , config ) ;
124
+ }
125
+
121
126
function globalMatchMethod ( event ) {
122
127
var selectedIndex = document . getElementById ( 'globalMatchMethodSelect' ) . selectedIndex ;
123
128
config . globalMatchMethod = selectedIndex ;
@@ -133,9 +138,39 @@ function importConfig(event) {
133
138
}
134
139
}
135
140
136
- function filterMethodSelect ( event ) {
137
- config . filterMethod = document . getElementById ( 'filterMethodSelect' ) . selectedIndex ;
138
- saveOptions ( event , config ) ;
141
+ // TODO: Migrate wordList to new words object
142
+ function migrateWordList ( ) {
143
+ chrome . storage . sync . get ( 'wordList' , function ( storage ) {
144
+ var wordListStr = storage . wordList ;
145
+
146
+ if ( wordListStr != undefined && wordListStr != '' ) {
147
+ var word = '' ;
148
+ var wordList = wordListStr . split ( ',' ) ;
149
+
150
+ try {
151
+ // Migrate to new words object
152
+ for ( i = 0 ; i < wordList . length ; i ++ ) {
153
+ word = wordList [ i ] ;
154
+ if ( word != "" ) {
155
+ if ( ! arrayContains ( Object . keys ( config . words ) , word ) ) {
156
+ console . log ( 'Migrating word: ' + word ) ;
157
+ config . words [ word ] = { "matchMethod" : 1 , "words" : [ ] } ;
158
+ } else {
159
+ console . log ( 'Word already in list: ' + word ) ;
160
+ }
161
+ }
162
+ }
163
+
164
+ // Remove wordList if successful
165
+ console . log ( wordListStr , wordList ) ;
166
+ saveOptions ( undefined , config ) ;
167
+ chrome . storage . sync . remove ( 'wordList' ) ;
168
+ }
169
+ catch ( error ) {
170
+ console . log ( 'Error: Aborting wordList migration!' , error ) ;
171
+ }
172
+ }
173
+ } ) ;
139
174
}
140
175
141
176
// Switching Tabs
@@ -162,6 +197,7 @@ function openTab(event) {
162
197
function populateOptions ( ) {
163
198
chrome . storage . sync . get ( defaults , function ( settings ) {
164
199
config = settings ; // Make config globally available
200
+ migrateWordList ( ) ; // TODO: Migrate wordList
165
201
166
202
// Show/hide censor options and word substitutions based on filter method
167
203
dynamicList ( filterMethods , 'filterMethodSelect' ) ;
0 commit comments