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 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 showIconNumber.setAttribute("aria-checked", Prefs.show_statsinicon); | 74 showIconNumber.setAttribute("aria-checked", Prefs.show_statsinicon); |
75 showIconNumber.addEventListener("click", toggleIconNumber, false); | 75 showIconNumber.addEventListener("click", toggleIconNumber, false); |
76 document.querySelector("label[for='show-iconnumber']").addEventListener("cli
ck", toggleIconNumber, false); | 76 document.querySelector("label[for='show-iconnumber']").addEventListener("cli
ck", toggleIconNumber, false); |
77 | 77 |
78 // Update stats | 78 // Update stats |
79 ext.pages.query({active: true, lastFocusedWindow: true}, function(pages) | 79 ext.pages.query({active: true, lastFocusedWindow: true}, function(pages) |
80 { | 80 { |
81 currentPage = pages[0]; | 81 currentPage = pages[0]; |
82 updateStats(); | 82 updateStats(); |
83 | 83 |
84 FilterNotifier.addListener(onNotify); | 84 FilterNotifier.on("filter.hitCount", updateStats); |
85 | 85 |
86 document.getElementById("stats-container").removeAttribute("hidden"); | 86 document.getElementById("stats-container").removeAttribute("hidden"); |
87 }); | 87 }); |
88 } | 88 } |
89 | 89 |
90 function onUnload() | 90 function onUnload() |
91 { | 91 { |
92 FilterNotifier.removeListener(onNotify); | 92 FilterNotifier.off("filter.hitCount", updateStats); |
93 } | |
94 | |
95 function onNotify(action, item) | |
96 { | |
97 if (action == "filter.hitCount") | |
98 updateStats(); | |
99 } | 93 } |
100 | 94 |
101 function updateStats() | 95 function updateStats() |
102 { | 96 { |
103 var statsPage = document.getElementById("stats-page"); | 97 var statsPage = document.getElementById("stats-page"); |
104 var blockedPage = getBlockedPerPage(currentPage).toLocaleString(); | 98 var blockedPage = getBlockedPerPage(currentPage).toLocaleString(); |
105 i18n.setElementText(statsPage, "stats_label_page", [blockedPage]); | 99 i18n.setElementText(statsPage, "stats_label_page", [blockedPage]); |
106 | 100 |
107 var statsTotal = document.getElementById("stats-total"); | 101 var statsTotal = document.getElementById("stats-total"); |
108 var blockedTotal = Prefs.blocked_total.toLocaleString(); | 102 var blockedTotal = Prefs.blocked_total.toLocaleString(); |
(...skipping 14 matching lines...) Expand all Loading... |
123 | 117 |
124 function toggleIconNumber() | 118 function toggleIconNumber() |
125 { | 119 { |
126 Prefs.show_statsinicon = !Prefs.show_statsinicon; | 120 Prefs.show_statsinicon = !Prefs.show_statsinicon; |
127 document.getElementById("show-iconnumber").setAttribute("aria-checked", Pref
s.show_statsinicon); | 121 document.getElementById("show-iconnumber").setAttribute("aria-checked", Pref
s.show_statsinicon); |
128 } | 122 } |
129 | 123 |
130 document.addEventListener("DOMContentLoaded", onLoad, false); | 124 document.addEventListener("DOMContentLoaded", onLoad, false); |
131 window.addEventListener("unload", onUnload, false); | 125 window.addEventListener("unload", onUnload, false); |
132 })(); | 126 })(); |
OLD | NEW |