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

Side by Side Diff: stats.js

Issue 29452181: Noissue - Merge current tip to Edge bookmark (Closed)
Patch Set: Created May 30, 2017, 3:49 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 | « qunit/tests/versionComparator.js ('k') | subscriptionLink.postload.js » ('j') | 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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2017 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 */
19
18 "use strict"; 20 "use strict";
19 21
22 (function()
20 { 23 {
21 const {require} = ext.backgroundPage.getWindow(); 24 const {require} = ext.backgroundPage.getWindow();
22 25
23 const {getBlockedPerPage} = require("stats"); 26 const {getBlockedPerPage} = require("stats");
24 const {FilterNotifier} = require("filterNotifier"); 27 const {FilterNotifier} = require("filterNotifier");
25 const {Prefs} = require("prefs"); 28 const {Prefs} = require("prefs");
26 29
27 let currentPage; 30 let currentPage;
28 const shareURL = "https://adblockplus.org/"; 31 const shareURL = "https://adblockplus.org/";
29 32
(...skipping 26 matching lines...) Expand all
56 { 59 {
57 let url = shareLinks[network][0]; 60 let url = shareLinks[network][0];
58 let params = shareLinks[network][1]; 61 let params = shareLinks[network][1];
59 62
60 let querystring = []; 63 let querystring = [];
61 for (let key in params) 64 for (let key in params)
62 { 65 {
63 let value = params[key]; 66 let value = params[key];
64 if (value == messageMark) 67 if (value == messageMark)
65 value = i18n.getMessage("stats_share_message", blockedCount); 68 value = i18n.getMessage("stats_share_message", blockedCount);
66 querystring.push(encodeURIComponent(key) + "=" + encodeURIComponent(value) ); 69 querystring.push(
70 encodeURIComponent(key) + "=" + encodeURIComponent(value)
71 );
67 } 72 }
68 return url + "?" + querystring.join("&"); 73 return url + "?" + querystring.join("&");
69 } 74 }
70 75
71 function onLoad() 76 function onLoad()
72 { 77 {
73 document.getElementById("share-box").addEventListener("click", share, false) ; 78 document.getElementById("share-box").addEventListener("click", share,
79 false);
74 let showIconNumber = document.getElementById("show-iconnumber"); 80 let showIconNumber = document.getElementById("show-iconnumber");
75 showIconNumber.setAttribute("aria-checked", Prefs.show_statsinicon); 81 showIconNumber.setAttribute("aria-checked", Prefs.show_statsinicon);
76 showIconNumber.addEventListener("click", toggleIconNumber, false); 82 showIconNumber.addEventListener("click", toggleIconNumber, false);
77 document.querySelector("label[for='show-iconnumber']").addEventListener("cli ck", toggleIconNumber, false); 83 document.querySelector("label[for='show-iconnumber']").addEventListener(
84 "click", toggleIconNumber, false
85 );
78 86
79 // Update stats 87 // Update stats
80 ext.pages.query({active: true, lastFocusedWindow: true}, pages => 88 ext.pages.query({active: true, lastFocusedWindow: true}, pages =>
81 { 89 {
82 currentPage = pages[0]; 90 currentPage = pages[0];
83 updateStats(); 91 updateStats();
84 92
85 FilterNotifier.on("filter.hitCount", updateStats); 93 FilterNotifier.on("filter.hitCount", updateStats);
86 94
87 document.getElementById("stats-container").removeAttribute("hidden"); 95 document.getElementById("stats-container").removeAttribute("hidden");
(...skipping 24 matching lines...) Expand all
112 blocked = blocked.toLocaleString(); 120 blocked = blocked.toLocaleString();
113 else 121 else
114 blocked = i18n.getMessage("stats_over", (9000).toLocaleString()); 122 blocked = i18n.getMessage("stats_over", (9000).toLocaleString());
115 123
116 ext.pages.open(createShareLink(ev.target.dataset.social, blocked)); 124 ext.pages.open(createShareLink(ev.target.dataset.social, blocked));
117 } 125 }
118 126
119 function toggleIconNumber() 127 function toggleIconNumber()
120 { 128 {
121 Prefs.show_statsinicon = !Prefs.show_statsinicon; 129 Prefs.show_statsinicon = !Prefs.show_statsinicon;
122 document.getElementById("show-iconnumber").setAttribute("aria-checked", Pref s.show_statsinicon); 130 document.getElementById("show-iconnumber").setAttribute(
131 "aria-checked", Prefs.show_statsinicon
132 );
123 } 133 }
124 134
125 document.addEventListener("DOMContentLoaded", onLoad, false); 135 document.addEventListener("DOMContentLoaded", onLoad, false);
126 window.addEventListener("unload", onUnload, false); 136 window.addEventListener("unload", onUnload, false);
127 } 137 }());
OLDNEW
« no previous file with comments | « qunit/tests/versionComparator.js ('k') | subscriptionLink.postload.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld