33/* exported persistChoices, restoreChoices, cache, readCache */
44
55/* global config, Store, getURLParam, iso639CodesInverse, pairs, refreshLangList populateSecondaryAnalyzerList,
6- populateSecondaryGeneratorList, isSubset, handleNewCurrentLang */
6+ populateSecondaryGeneratorList, populateSecondarySpellcheckerList, isSubset, handleNewCurrentLang */
77/* global srcLangs, dstLangs, recentSrcLangs, recentDstLangs, setCurDstLang, setCurSrcLang, setRecentDstLangs, setRecentSrcLangs, setLocale,
88 curSrcLang, curDstLang, locale */
99
@@ -73,6 +73,14 @@ function persistChoices(mode /*: string */, updatePermalink /*: ?boolean */) {
7373 'generatorInput' : $ ( '#morphGeneratorInput' ) . val ( )
7474 } ;
7575 }
76+ else if ( mode === 'spellchecker' ) {
77+ objects = {
78+ 'primarySpellcheckerChoice' : $ ( '#primarySpellcheckerMode' ) . val ( ) ,
79+ 'secondarySpellcheckerChoice' : $ ( '#secondarySpellcheckerMode' ) . val ( ) ,
80+ 'spellcheckerInput' : $ ( '#spellcheckerInput' ) . text ( ) ,
81+ 'instantChecking' : $ ( '#instantChecking' ) . val ( )
82+ } ;
83+ }
7684 else if ( mode === 'localization' ) {
7785 objects = {
7886 'locale' : $ ( '.localeSelect' ) . val ( )
@@ -122,6 +130,11 @@ function persistChoices(mode /*: string */, updatePermalink /*: ?boolean */) {
122130 urlParams . push ( 'choice=' + encodeURIComponent ( $ ( '#secondaryGeneratorMode' ) . val ( ) ) ) ;
123131 qVal = $ ( '#morphGeneratorInput' ) . val ( ) ;
124132 }
133+ else if ( hash === '#spellchecker' && $ ( '#secondarySpellcheckerMode' ) . val ( ) ) {
134+ urlParams = [ ] ;
135+ urlParams . push ( 'choice=' + encodeURIComponent ( $ ( '#secondarySpellcheckerMode' ) . val ( ) ) ) ;
136+ qVal = $ ( '#spellcheckerInput' ) . text ( ) ;
137+ }
125138
126139 var qName /*: string */ = HASH_URL_MAP [ hash ] ;
127140
@@ -266,6 +279,33 @@ function restoreChoices(mode /*: string */) {
266279 $ ( '#morphGeneratorInput' ) . val ( decodeURIComponent ( getURLParam ( 'qG' ) ) ) ;
267280 }
268281 }
282+ else if ( mode === 'spellchecker' ) {
283+ if ( store . able ( ) ) {
284+ var primarySpellcheckerChoice = store . get ( 'primarySpellcheckerChoice' , '' ) ,
285+ secondarySpellcheckerChoice = store . get ( 'secondarySpellcheckerChoice' , '' ) ;
286+ if ( store . has ( 'primarySpellcheckerChoice' ) && store . has ( 'secondarySpellcheckerChoice' ) ) {
287+ $ ( '#primarySpellcheckerMode option[value="' + primarySpellcheckerChoice + '"]' ) . prop ( 'selected' , true ) ;
288+ populateSecondarySpellcheckerList ( ) ;
289+ $ ( '#secondarySpellcheckerMode option[value="' + secondarySpellcheckerChoice + '"]' ) . prop ( 'selected' , true ) ;
290+ }
291+ else {
292+ populateSecondarySpellcheckerList ( ) ;
293+ }
294+ if ( store . has ( 'spellcheckerInput' ) ) {
295+ $ ( '#spellcheckerInput' ) . text ( store . get ( 'spellcheckerInput' ) ) ;
296+ $ ( '#instantChecking' ) . prop ( 'checked' , store . get ( 'instantChecking' , true ) ) ;
297+ }
298+ }
299+
300+ if ( getURLParam ( 'choice' ) ) {
301+ choice = getURLParam ( 'choice' ) . split ( '-' ) ;
302+ $ ( '#primarySpellcheckerMode option[value="' + choice [ 0 ] + '"]' ) . prop ( 'selected' , true ) ;
303+ populateSecondarySpellcheckerList ( ) ;
304+ if ( choice . length === 2 ) {
305+ $ ( '#secondarySpellcheckerMode option[value="' + choice . join ( '-' ) + '"]' ) . prop ( 'selected' , true ) ;
306+ }
307+ }
308+ }
269309 else if ( mode === 'localization' ) {
270310 if ( store . able ( ) ) {
271311 setLocale ( store . get ( 'locale' , '' ) ) ;
@@ -289,5 +329,6 @@ function restoreChoices(mode /*: string */) {
289329/*:: import {iso639Codes, iso639CodesInverse, locale, setLocale} from "./localization.js" */
290330/*:: import {populateSecondaryGeneratorList} from "./generator.js" */
291331/*:: import {populateSecondaryAnalyzerList} from "./analyzer.js" */
332+ /*:: import {populateSecondarySpellcheckerList} from "./spellchecker.js" */
292333/*:: import {getURLParam, isSubset} from "./util.js" */
293334/*:: import {Store} from "./store.js" */
0 commit comments