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

Side by Side Diff: stats.js

Issue 29567782: Issue 5593 - Stop updating the stats in the popup in real-time (Closed)
Patch Set: Created Oct. 6, 2017, 1:51 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 <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present 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 /* global i18n, getPref, togglePref */ 18 /* global i18n, getPref, togglePref */
19 19
20 "use strict"; 20 "use strict";
21 21
22 (function() 22 (function()
23 { 23 {
24 const {require} = ext.backgroundPage.getWindow();
25
26 const {FilterNotifier} = require("filterNotifier");
27
28 let currentTab; 24 let currentTab;
29 const shareURL = "https://adblockplus.org/"; 25 const shareURL = "https://adblockplus.org/";
30 26
31 let messageMark = {}; 27 let messageMark = {};
32 let shareLinks = { 28 let shareLinks = {
33 facebook: ["https://www.facebook.com/dialog/feed", { 29 facebook: ["https://www.facebook.com/dialog/feed", {
34 app_id: "475542399197328", 30 app_id: "475542399197328",
35 link: shareURL, 31 link: shareURL,
36 redirect_uri: "https://www.facebook.com/", 32 redirect_uri: "https://www.facebook.com/",
37 ref: "adcounter", 33 ref: "adcounter",
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 document.querySelector("label[for='show-iconnumber']").addEventListener( 80 document.querySelector("label[for='show-iconnumber']").addEventListener(
85 "click", toggleIconNumber, false 81 "click", toggleIconNumber, false
86 ); 82 );
87 83
88 // Update stats 84 // Update stats
89 chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => 85 chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs =>
90 { 86 {
91 currentTab = tabs[0]; 87 currentTab = tabs[0];
92 updateStats(); 88 updateStats();
93 89
94 FilterNotifier.on("filter.hitCount", updateStats);
95
96 document.getElementById("stats-container").removeAttribute("hidden"); 90 document.getElementById("stats-container").removeAttribute("hidden");
97 }); 91 });
98 } 92 }
99 93
100 function onUnload()
101 {
102 FilterNotifier.off("filter.hitCount", updateStats);
103 }
104
105 function updateStats() 94 function updateStats()
106 { 95 {
107 let statsPage = document.getElementById("stats-page"); 96 let statsPage = document.getElementById("stats-page");
108 chrome.runtime.sendMessage({ 97 chrome.runtime.sendMessage({
109 type: "stats.getBlockedPerPage", 98 type: "stats.getBlockedPerPage",
110 tab: currentTab 99 tab: currentTab
111 }, 100 },
112 blockedPage => 101 blockedPage =>
113 { 102 {
114 i18n.setElementText(statsPage, "stats_label_page", 103 i18n.setElementText(statsPage, "stats_label_page",
(...skipping 26 matching lines...) Expand all
141 { 130 {
142 togglePref("show_statsinicon", showStatsInIcon => 131 togglePref("show_statsinicon", showStatsInIcon =>
143 { 132 {
144 document.getElementById("show-iconnumber").setAttribute( 133 document.getElementById("show-iconnumber").setAttribute(
145 "aria-checked", showStatsInIcon 134 "aria-checked", showStatsInIcon
146 ); 135 );
147 }); 136 });
148 } 137 }
149 138
150 document.addEventListener("DOMContentLoaded", onLoad, false); 139 document.addEventListener("DOMContentLoaded", onLoad, false);
151 window.addEventListener("unload", onUnload, false);
152 }()); 140 }());
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