@@ -10,13 +10,23 @@ function showSavedAlert() {
1010
1111function setInitialState ( ) {
1212 chrome . storage . sync . get ( {
13- shouldOpenInSameTab : true
13+ shouldOpenInSameTab : true ,
14+ questionsWithCodeFilter : false ,
15+ communityWikisFilter : false ,
16+ duplicateQuestionsFilter : false ,
17+ answerTypeFilter : 0 ,
18+ customFilter : ""
1419 } , function ( items ) {
1520 if ( items . shouldOpenInSameTab ) {
1621 document . getElementById ( 'same_tab_result' ) . checked = true ;
1722 } else {
1823 document . getElementById ( 'new_tab_result' ) . checked = true ;
1924 }
25+ document . getElementById ( 'question_with_code' ) . checked = items . questionsWithCodeFilter ;
26+ document . getElementById ( 'community_wikis' ) . checked = items . communityWikisFilter ;
27+ document . getElementById ( 'duplicate_questions' ) . checked = items . duplicateQuestionsFilter ;
28+ document . getElementById ( 'answer_type' ) . options . selectedIndex = items . answerTypeFilter ;
29+ document . getElementById ( 'custom_filter' ) . value = items . customFilter ;
2030 } ) ;
2131}
2232
@@ -28,6 +38,41 @@ function setListeners() {
2838 showSavedAlert ( ) ;
2939 } ) ;
3040 } ) ;
41+ $ ( "#question_with_code" ) . on ( "change" , function ( ) {
42+ chrome . storage . sync . set ( {
43+ questionsWithCodeFilter : this . checked
44+ } , function ( ) {
45+ showSavedAlert ( ) ;
46+ } ) ;
47+ } ) ;
48+ $ ( "#community_wikis" ) . on ( "change" , function ( ) {
49+ chrome . storage . sync . set ( {
50+ communityWikisFilter : this . checked
51+ } , function ( ) {
52+ showSavedAlert ( ) ;
53+ } ) ;
54+ } ) ;
55+ $ ( "#duplicate_questions" ) . on ( "change" , function ( ) {
56+ chrome . storage . sync . set ( {
57+ duplicateQuestionsFilter : this . checked
58+ } , function ( ) {
59+ showSavedAlert ( ) ;
60+ } ) ;
61+ } ) ;
62+ $ ( "#answer_type" ) . on ( "change" , function ( ) {
63+ chrome . storage . sync . set ( {
64+ answerTypeFilter : this . value
65+ } , function ( ) {
66+ showSavedAlert ( ) ;
67+ } ) ;
68+ } ) ;
69+ $ ( "#custom_filter" ) . on ( "input" , function ( ) {
70+ chrome . storage . sync . set ( {
71+ customFilter : this . value
72+ } , function ( ) {
73+ showSavedAlert ( ) ;
74+ } ) ;
75+ } ) ;
3176}
3277
3378setInitialState ( ) ;
0 commit comments