Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 20 matching lines...) Expand all Loading... | |
31 * @param {String} key field key | 31 * @param {String} key field key |
32 * @param {Number} tabId tab ID (leave undefined for total stats) | 32 * @param {Number} tabId tab ID (leave undefined for total stats) |
33 * @return {Number} field value | 33 * @return {Number} field value |
34 */ | 34 */ |
35 let getStats = exports.getStats = function getStats(key, tab) | 35 let getStats = exports.getStats = function getStats(key, tab) |
36 { | 36 { |
37 if (!tab) | 37 if (!tab) |
38 return (key in Prefs.stats_total ? Prefs.stats_total[key] : 0); | 38 return (key in Prefs.stats_total ? Prefs.stats_total[key] : 0); |
39 | 39 |
40 let tabStats = statsPerTab.get(tab); | 40 let tabStats = statsPerTab.get(tab); |
41 return tabStats && tabStats.blocked || 0; | 41 return tabStats ? tabStats.blocked : 0; |
Felix Dahlke
2014/01/18 13:39:19
We're typically not using and/or as branching oper
Sebastian Noack
2014/01/19 10:19:40
Done.
| |
42 }; | 42 }; |
43 | 43 |
44 FilterNotifier.addListener(function(action, item, newValue, oldValue, tab) | 44 FilterNotifier.addListener(function(action, item, newValue, oldValue, tab) |
45 { | 45 { |
46 if (action != "filter.hitCount" || !tab) | 46 if (action != "filter.hitCount" || !tab) |
47 return; | 47 return; |
48 | 48 |
49 let blocked = item instanceof BlockingFilter; | 49 let blocked = item instanceof BlockingFilter; |
50 | 50 |
51 // Increment counts | 51 // Increment counts |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 { | 113 { |
114 badge = { | 114 badge = { |
115 color: badgeColor, | 115 color: badgeColor, |
116 number: tabStats.blocked | 116 number: tabStats.blocked |
117 }; | 117 }; |
118 } | 118 } |
119 } | 119 } |
120 tab.browserAction.setBadge(badge); | 120 tab.browserAction.setBadge(badge); |
121 }); | 121 }); |
122 }); | 122 }); |
LEFT | RIGHT |