LEFT | RIGHT |
1 function init() | 1 function init() |
2 { | 2 { |
3 try | 3 try |
4 { | 4 { |
5 initLanguageSettings(); | 5 initLanguageSettings(); |
6 | 6 |
7 initDomainSettings(); | 7 initDomainSettings(); |
8 } | 8 } |
9 catch (err) | 9 catch (err) |
10 { | 10 { |
11 //alert("err: " + err); | 11 //alert("err: " + err); |
12 } | 12 } |
13 } | 13 } |
14 | 14 |
15 function setElementText(id, key) | 15 function setElementText(id, key) |
16 { | 16 { |
17 var el = document.getElementById(id); | 17 var el = document.getElementById(id); |
18 if (el) | 18 if (el) |
19 { | 19 { |
20 var text = UserSettings().GetMessage("settings", key); | 20 var text = UserSettings().GetMessage("settings", key); |
21 if (text) | 21 if (text) |
22 { | 22 { |
23 el.innerText = text; | 23 el.innerText = text; |
24 } | 24 } |
25 } | 25 } |
26 } | 26 } |
27 | 27 |
28 function setCheckboxCheck(id, val) | 28 function acceptableAdsChange() |
29 { | 29 { |
30 var el = document.getElementById(id); | 30 var aaCheckbox = document.getElementById("acceptableAdsCheckbox"); |
31 if (el) | 31 UserSettings().SetAcceptableAdsEnabled(aaCheckbox.checked); |
32 { | |
33 el.checked = val; | |
34 } | |
35 } | |
36 | |
37 function acceptableAdsChange(cb) | |
38 { | |
39 UserSettings().SetAcceptableAdsEnabled(cb.checked); | |
40 } | 32 } |
41 | 33 |
42 function initLanguageSettings() | 34 function initLanguageSettings() |
43 { | 35 { |
44 setElementText("title", "settings-title"); | 36 setElementText("title", "settings-title"); |
45 | 37 |
46 setElementText("localeLanguageLabel", "settings-language-label"); | 38 setElementText("localeLanguageLabel", "settings-language-label"); |
47 setElementText("localeLanguageDescription", "settings-language-description"); | 39 setElementText("localeLanguageDescription", "settings-language-description"); |
48 | 40 |
49 setElementText("localeBlockingLabel", "settings-blocking-label"); | 41 setElementText("localeBlockingLabel", "settings-blocking-label"); |
50 setElementText("localeBlockingDescription", "settings-blocking-description"); | 42 setElementText("localeBlockingDescription", "settings-blocking-description"); |
51 | 43 |
52 setElementText("manageExceptions", "settings-exceptions-manage-label"); | 44 setElementText("manageExceptions", "settings-exceptions-manage-label"); |
53 setElementText("addDomain", "settings-exceptions-add-label"); | 45 setElementText("addDomain", "settings-exceptions-add-label"); |
54 setElementText("removeDomains", "settings-exceptions-remove-label"); | 46 setElementText("removeDomains", "settings-exceptions-remove-label"); |
55 | 47 |
56 setElementText("localeWorthSharing", "settings-share-label"); | 48 setElementText("localeWorthSharing", "settings-share-label"); |
57 | 49 |
58 setElementText("acceptableAdsLabel", "settings-acceptable-ads"); | 50 setElementText("acceptableAdsLabel", "settings-acceptable-ads"); |
59 | 51 |
60 setCheckboxCheck("acceptableAdsCheckbox", UserSettings().IsAcceptableAdsEnable
d()); | 52 var aaCheckbox = document.getElementById("acceptableAdsCheckbox"); |
| 53 if (aaCheckbox) |
| 54 { |
| 55 aaCheckbox.checked = UserSettings().IsAcceptableAdsEnabled(); |
| 56 addListener(aaCheckbox, "change", acceptableAdsChange, false); |
| 57 } |
61 | 58 |
62 var optionsLanguage = document.getElementById("language"); | 59 var optionsLanguage = document.getElementById("language"); |
63 | 60 |
64 var languageCount = UserSettings().GetLanguageCount(); | 61 var languageCount = UserSettings().GetLanguageCount(); |
65 for(var i = 0; i < languageCount; i++) | 62 for(var i = 0; i < languageCount; i++) |
66 { | 63 { |
67 var el = document.createElement("option"); | 64 var el = document.createElement("option"); |
68 el.text = UserSettings().GetLanguageTitleByIndex(i); | 65 el.text = UserSettings().GetLanguageTitleByIndex(i); |
69 el.value = UserSettings().GetLanguageByIndex(i); | 66 el.value = UserSettings().GetLanguageByIndex(i); |
70 | 67 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 { | 156 { |
160 optionsDomain.remove(removeOptions[i]); | 157 optionsDomain.remove(removeOptions[i]); |
161 } | 158 } |
162 }, false); | 159 }, false); |
163 } | 160 } |
164 | 161 |
165 window.UserSettings = function() | 162 window.UserSettings = function() |
166 { | 163 { |
167 return window.Settings; | 164 return window.Settings; |
168 } | 165 } |
LEFT | RIGHT |