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

Side by Side Diff: stats.js

Issue 5968535989780480: Issue 2567 - Simplified stats data structure, fixed regression resetting ad counter (Closed)
Patch Set: Created May 22, 2015, 1:07 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 | « lib/stats.js ('k') | 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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 (function() 18 (function()
19 { 19 {
20 var backgroundPage = ext.backgroundPage.getWindow(); 20 var backgroundPage = ext.backgroundPage.getWindow();
21 var require = backgroundPage.require; 21 var require = backgroundPage.require;
22 var getStats = require("stats").getStats; 22 var getBlockedPerPage = require("stats").getBlockedPerPage;
23 var FilterNotifier = require("filterNotifier").FilterNotifier; 23 var FilterNotifier = require("filterNotifier").FilterNotifier;
24 var Prefs = require("prefs").Prefs; 24 var Prefs = require("prefs").Prefs;
25 25
26 var currentPage; 26 var currentPage;
27 var shareURL = "https://adblockplus.org/"; 27 var shareURL = "https://adblockplus.org/";
28 28
29 var messageMark = {}; 29 var messageMark = {};
30 var shareLinks = { 30 var shareLinks = {
31 facebook: ["https://www.facebook.com/dialog/feed", { 31 facebook: ["https://www.facebook.com/dialog/feed", {
32 app_id: "475542399197328", 32 app_id: "475542399197328",
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 function onNotify(action, item) 95 function onNotify(action, item)
96 { 96 {
97 if (action == "filter.hitCount") 97 if (action == "filter.hitCount")
98 updateStats(); 98 updateStats();
99 } 99 }
100 100
101 function updateStats() 101 function updateStats()
102 { 102 {
103 var statsPage = document.getElementById("stats-page"); 103 var statsPage = document.getElementById("stats-page");
104 var blockedPage = getStats("blocked", currentPage).toLocaleString(); 104 var blockedPage = getBlockedPerPage(currentPage).toLocaleString();
105 i18n.setElementText(statsPage, "stats_label_page", [blockedPage]); 105 i18n.setElementText(statsPage, "stats_label_page", [blockedPage]);
106 106
107 var statsTotal = document.getElementById("stats-total"); 107 var statsTotal = document.getElementById("stats-total");
108 var blockedTotal = getStats("blocked").toLocaleString(); 108 var blockedTotal = Prefs.blocked_total.toLocaleString();
109 i18n.setElementText(statsTotal, "stats_label_total", [blockedTotal]); 109 i18n.setElementText(statsTotal, "stats_label_total", [blockedTotal]);
110 } 110 }
111 111
112 function share(ev) 112 function share(ev)
113 { 113 {
114 // Easter Egg 114 // Easter Egg
115 var blocked = getStats("blocked"); 115 var blocked = Prefs.blocked_total;
116 if (blocked <= 9000 || blocked >= 10000) 116 if (blocked <= 9000 || blocked >= 10000)
117 blocked = blocked.toLocaleString(); 117 blocked = blocked.toLocaleString();
118 else 118 else
119 blocked = i18n.getMessage("stats_over", (9000).toLocaleString()); 119 blocked = i18n.getMessage("stats_over", (9000).toLocaleString());
120 120
121 ext.pages.open(createShareLink(ev.target.dataset.social, blocked)); 121 ext.pages.open(createShareLink(ev.target.dataset.social, blocked));
122 } 122 }
123 123
124 function toggleIconNumber() 124 function toggleIconNumber()
125 { 125 {
126 Prefs.show_statsinicon = !Prefs.show_statsinicon; 126 Prefs.show_statsinicon = !Prefs.show_statsinicon;
127 document.getElementById("show-iconnumber").setAttribute("aria-checked", Pref s.show_statsinicon); 127 document.getElementById("show-iconnumber").setAttribute("aria-checked", Pref s.show_statsinicon);
128 } 128 }
129 129
130 document.addEventListener("DOMContentLoaded", onLoad, false); 130 document.addEventListener("DOMContentLoaded", onLoad, false);
131 window.addEventListener("unload", onUnload, false); 131 window.addEventListener("unload", onUnload, false);
132 })(); 132 })();
OLDNEW
« no previous file with comments | « lib/stats.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld