Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: chrome/content/ui/filters.js

Issue 6337686776315904: Issue 394 - hit statistics tool data collection (Closed)
Left Patch Set: Addressed Wladimir comments (save data in the database instead of memory) Created Feb. 19, 2016, 5:20 p.m.
Right Patch Set: Use Downloader to send the data to server Created April 6, 2016, 3 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | chrome/content/ui/filters.xul » ('j') | lib/filterHits.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
20 /** 18 /**
21 * Initialization function, called when the window is loaded. 19 * Initialization function, called when the window is loaded.
22 */ 20 */
23 function init() 21 function init()
24 { 22 {
25 if (window.arguments && window.arguments.length) 23 if (window.arguments && window.arguments.length)
26 { 24 {
27 let filter = window.arguments[0].wrappedJSObject; 25 let filter = window.arguments[0].wrappedJSObject;
28 if (filter instanceof Filter) 26 if (filter instanceof Filter)
29 Utils.runAsync(() => SubscriptionActions.selectFilter(filter)); 27 Utils.runAsync(() => SubscriptionActions.selectFilter(filter));
30 } 28 }
31 29
32 E("sendStats").hidden = !Prefs.savestats; 30 E("sendStats-container").hidden = !Prefs.savestats;
33 E("sendStats").getElementsByTagName("checkbox")[0].checked = Prefs.sendstats; 31 E("sendStats").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) 32 Prefs.addListener(function(name)
35 { 33 {
36 if (name == "savestats") 34 if (name == "savestats")
37 E("sendStats").hidden = !Prefs[name]; 35 E("sendStats-container").hidden = !Prefs.savestats;
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.
36 else if (name == "sendstats")
37 E("sendStats").checked = Prefs.sendstats;
38 }); 38 });
39 } 39 }
40 40
41 /** 41 /**
42 * Called whenever the currently selected tab changes. 42 * Called whenever the currently selected tab changes.
43 */ 43 */
44 function onTabChange(/**Element*/ tabbox) 44 function onTabChange(/**Element*/ tabbox)
45 { 45 {
46 updateSelectedSubscription(); 46 updateSelectedSubscription();
47 47
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 /** 128 /**
129 * Processes a template node using given data object. 129 * Processes a template node using given data object.
130 */ 130 */
131 process: function(/**Node*/ template, /**Object*/ data) /**Node*/ 131 process: function(/**Node*/ template, /**Object*/ data) /**Node*/
132 { 132 {
133 // Use a sandbox to resolve attributes (for convenience, not security) 133 // Use a sandbox to resolve attributes (for convenience, not security)
134 let sandbox = Cu.Sandbox(window); 134 let sandbox = Cu.Sandbox(window);
135 for (let key in data) 135 for (let key in data)
136 sandbox[key] = data[key]; 136 sandbox[key] = data[key];
137 sandbox.formatTime = Utils.formatTime; 137 sandbox.formatTime = Utils.formatTime;
138 sandbox.getSubscriptionTitle = getSubscriptionTitle;
138 139
139 // Clone template but remove id/hidden attributes from it 140 // Clone template but remove id/hidden attributes from it
140 let result = template.cloneNode(true); 141 let result = template.cloneNode(true);
141 result.removeAttribute("id"); 142 result.removeAttribute("id");
142 result.removeAttribute("hidden"); 143 result.removeAttribute("hidden");
143 result._data = data; 144 result._data = data;
144 145
145 // Resolve any attributes of the for attr="{obj.foo}" 146 // Resolve any attributes of the for attr="{obj.foo}"
146 let conditionals = []; 147 let conditionals = [];
147 let nodeIterator = document.createNodeIterator(result, NodeFilter.SHOW_ELEME NT, null, false); 148 let nodeIterator = document.createNodeIterator(result, NodeFilter.SHOW_ELEME NT, null, false);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 * data object. 236 * data object.
236 */ 237 */
237 getNodeForData: function(/**Node*/ parent, /**String*/ property, /**Object*/ d ata) /**Node*/ 238 getNodeForData: function(/**Node*/ parent, /**String*/ property, /**Object*/ d ata) /**Node*/
238 { 239 {
239 for (let child = parent.firstChild; child; child = child.nextSibling) 240 for (let child = parent.firstChild; child; child = child.nextSibling)
240 if ("_data" in child && property in child._data && child._data[property] = = data) 241 if ("_data" in child && property in child._data && child._data[property] = = data)
241 return child; 242 return child;
242 return null; 243 return null;
243 } 244 }
244 }; 245 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld