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

Side by Side Diff: lib/stats.js

Issue 5855687158530048: Issue 348 - Fixed bug when updating badge in response to preference change (Closed)
Patch Set: Created April 18, 2014, 8:21 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 }); 77 });
78 } 78 }
79 } 79 }
80 }); 80 });
81 81
82 Prefs.addListener(function(name) 82 Prefs.addListener(function(name)
83 { 83 {
84 if (name != "show_statsinicon") 84 if (name != "show_statsinicon")
85 return; 85 return;
86 86
87 ext.pages.query({}, function(page) 87 ext.pages.query({}, function(pages)
88 { 88 {
89 let badge = null; 89 for (var i = 0; i < pages.length; i++)
90 if (Prefs.show_statsinicon)
91 { 90 {
92 let pageStats = statsPerPage.get(page); 91 let page = pages[i];
93 if (pageStats && "blocked" in pageStats) 92 let badge = null;
93
94 if (Prefs.show_statsinicon)
94 { 95 {
95 badge = { 96 let pageStats = statsPerPage.get(page);
96 color: badgeColor, 97 if (pageStats && "blocked" in pageStats)
97 number: pageStats.blocked 98 {
98 }; 99 badge = {
100 color: badgeColor,
101 number: pageStats.blocked
102 };
103 }
99 } 104 }
105
106 page.browserAction.setBadge(badge);
100 } 107 }
101 page.browserAction.setBadge(badge);
102 }); 108 });
103 }); 109 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld