Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 let {Prefs} = require("prefs"); | |
19 | |
18 /** | 20 /** |
19 * Initialization function, called when the window is loaded. | 21 * Initialization function, called when the window is loaded. |
20 */ | 22 */ |
21 function init() | 23 function init() |
22 { | 24 { |
23 if (window.arguments && window.arguments.length) | 25 if (window.arguments && window.arguments.length) |
24 { | 26 { |
25 let filter = window.arguments[0].wrappedJSObject; | 27 let filter = window.arguments[0].wrappedJSObject; |
26 if (filter instanceof Filter) | 28 if (filter instanceof Filter) |
27 Utils.runAsync(() => SubscriptionActions.selectFilter(filter)); | 29 Utils.runAsync(() => SubscriptionActions.selectFilter(filter)); |
28 } | 30 } |
31 | |
32 E("sendStats").hidden = !Prefs.savestats; | |
33 E("sendStats").getElementsByTagName("checkbox")[0].checked = Prefs.sendstats; | |
Wladimir Palant
2016/02/29 14:35:43
Please don't access elements like that, they shoul
saroyanm
2016/03/18 18:23:11
Done.
| |
34 Prefs.addListener(function(name) | |
35 { | |
36 if (name == "savestats") | |
37 E("sendStats").hidden = !Prefs[name]; | |
Wladimir Palant
2016/02/29 14:35:43
Nit: No point obfuscating this - just use Prefs.sa
saroyanm
2016/03/18 18:23:11
Done.
| |
38 }); | |
29 } | 39 } |
30 | 40 |
31 /** | 41 /** |
32 * Called whenever the currently selected tab changes. | 42 * Called whenever the currently selected tab changes. |
33 */ | 43 */ |
34 function onTabChange(/**Element*/ tabbox) | 44 function onTabChange(/**Element*/ tabbox) |
35 { | 45 { |
36 updateSelectedSubscription(); | 46 updateSelectedSubscription(); |
37 | 47 |
38 Utils.runAsync(function() | 48 Utils.runAsync(function() |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 let list = panel.getElementsByTagName("richlistbox")[0]; | 105 let list = panel.getElementsByTagName("richlistbox")[0]; |
96 if (!list) | 106 if (!list) |
97 return; | 107 return; |
98 | 108 |
99 let data = Templater.getDataForNode(list.selectedItem); | 109 let data = Templater.getDataForNode(list.selectedItem); |
100 FilterView.subscription = (data ? data.subscription : null); | 110 FilterView.subscription = (data ? data.subscription : null); |
101 FilterActions.updateCommands(); | 111 FilterActions.updateCommands(); |
102 } | 112 } |
103 | 113 |
104 /** | 114 /** |
115 * Toggles option for sending filter hit statistics. | |
116 */ | |
117 function toggleSendStats(/**Boolean*/ allow) | |
118 { | |
119 Prefs.sendstats = allow; | |
120 } | |
121 | |
122 /** | |
105 * Template processing functions. | 123 * Template processing functions. |
106 * @class | 124 * @class |
107 */ | 125 */ |
108 var Templater = | 126 var Templater = |
109 { | 127 { |
110 /** | 128 /** |
111 * Processes a template node using given data object. | 129 * Processes a template node using given data object. |
112 */ | 130 */ |
113 process: function(/**Node*/ template, /**Object*/ data) /**Node*/ | 131 process: function(/**Node*/ template, /**Object*/ data) /**Node*/ |
114 { | 132 { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 * data object. | 235 * data object. |
218 */ | 236 */ |
219 getNodeForData: function(/**Node*/ parent, /**String*/ property, /**Object*/ d ata) /**Node*/ | 237 getNodeForData: function(/**Node*/ parent, /**String*/ property, /**Object*/ d ata) /**Node*/ |
220 { | 238 { |
221 for (let child = parent.firstChild; child; child = child.nextSibling) | 239 for (let child = parent.firstChild; child; child = child.nextSibling) |
222 if ("_data" in child && property in child._data && child._data[property] = = data) | 240 if ("_data" in child && property in child._data && child._data[property] = = data) |
223 return child; | 241 return child; |
224 return null; | 242 return null; |
225 } | 243 } |
226 }; | 244 }; |
OLD | NEW |