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

Side by Side Diff: stats.js

Issue 29569649: Issue 4580 - Replace ext.i18n with i18n (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Update adblockplusui dependency again Created Oct. 10, 2017, 4:31 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/utils.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-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 getPref, togglePref */
19 19
20 "use strict"; 20 "use strict";
21 21
22 (function() 22 (function()
23 { 23 {
24 let currentTab; 24 let currentTab;
25 const shareURL = "https://adblockplus.org/"; 25 const shareURL = "https://adblockplus.org/";
26 26
27 let messageMark = {}; 27 let messageMark = {};
28 let shareLinks = { 28 let shareLinks = {
29 facebook: ["https://www.facebook.com/dialog/feed", { 29 facebook: ["https://www.facebook.com/dialog/feed", {
30 app_id: "475542399197328", 30 app_id: "475542399197328",
31 link: shareURL, 31 link: shareURL,
32 redirect_uri: "https://www.facebook.com/", 32 redirect_uri: "https://www.facebook.com/",
33 ref: "adcounter", 33 ref: "adcounter",
34 name: messageMark, 34 name: messageMark,
35 actions: JSON.stringify([ 35 actions: JSON.stringify([
36 { 36 {
37 name: i18n.getMessage("stats_share_download"), 37 name: chrome.i18n.getMessage("stats_share_download"),
38 link: shareURL 38 link: shareURL
39 } 39 }
40 ]) 40 ])
41 }], 41 }],
42 gplus: ["https://plus.google.com/share", { 42 gplus: ["https://plus.google.com/share", {
43 url: shareURL 43 url: shareURL
44 }], 44 }],
45 twitter: ["https://twitter.com/intent/tweet", { 45 twitter: ["https://twitter.com/intent/tweet", {
46 text: messageMark, 46 text: messageMark,
47 url: shareURL, 47 url: shareURL,
48 via: "AdblockPlus" 48 via: "AdblockPlus"
49 }] 49 }]
50 }; 50 };
51 51
52 function createShareLink(network, blockedCount) 52 function createShareLink(network, blockedCount)
53 { 53 {
54 let url = shareLinks[network][0]; 54 let url = shareLinks[network][0];
55 let params = shareLinks[network][1]; 55 let params = shareLinks[network][1];
56 56
57 let querystring = []; 57 let querystring = [];
58 for (let key in params) 58 for (let key in params)
59 { 59 {
60 let value = params[key]; 60 let value = params[key];
61 if (value == messageMark) 61 if (value == messageMark)
62 value = i18n.getMessage("stats_share_message", blockedCount); 62 value = chrome.i18n.getMessage("stats_share_message", blockedCount);
63 querystring.push( 63 querystring.push(
64 encodeURIComponent(key) + "=" + encodeURIComponent(value) 64 encodeURIComponent(key) + "=" + encodeURIComponent(value)
65 ); 65 );
66 } 66 }
67 return url + "?" + querystring.join("&"); 67 return url + "?" + querystring.join("&");
68 } 68 }
69 69
70 function onLoad() 70 function onLoad()
71 { 71 {
72 document.getElementById("share-box").addEventListener("click", share, 72 document.getElementById("share-box").addEventListener("click", share,
(...skipping 20 matching lines...) Expand all
93 93
94 function updateStats() 94 function updateStats()
95 { 95 {
96 let statsPage = document.getElementById("stats-page"); 96 let statsPage = document.getElementById("stats-page");
97 chrome.runtime.sendMessage({ 97 chrome.runtime.sendMessage({
98 type: "stats.getBlockedPerPage", 98 type: "stats.getBlockedPerPage",
99 tab: currentTab 99 tab: currentTab
100 }, 100 },
101 blockedPage => 101 blockedPage =>
102 { 102 {
103 i18n.setElementText(statsPage, "stats_label_page", 103 ext.i18n.setElementText(statsPage, "stats_label_page",
104 [blockedPage.toLocaleString()]); 104 [blockedPage.toLocaleString()]);
105 }); 105 });
106 106
107 let statsTotal = document.getElementById("stats-total"); 107 let statsTotal = document.getElementById("stats-total");
108 getPref("blocked_total", blockedTotal => 108 getPref("blocked_total", blockedTotal =>
109 { 109 {
110 i18n.setElementText(statsTotal, "stats_label_total", 110 ext.i18n.setElementText(statsTotal, "stats_label_total",
111 [blockedTotal.toLocaleString()]); 111 [blockedTotal.toLocaleString()]);
112 }); 112 });
113 } 113 }
114 114
115 function share(ev) 115 function share(ev)
116 { 116 {
117 getPref("blocked_total", blockedTotal => 117 getPref("blocked_total", blockedTotal =>
118 { 118 {
119 // Easter Egg 119 // Easter Egg
120 if (blockedTotal <= 9000 || blockedTotal >= 10000) 120 if (blockedTotal <= 9000 || blockedTotal >= 10000)
121 {
121 blockedTotal = blockedTotal.toLocaleString(); 122 blockedTotal = blockedTotal.toLocaleString();
123 }
122 else 124 else
123 blockedTotal = i18n.getMessage("stats_over", (9000).toLocaleString()); 125 {
126 blockedTotal = chrome.i18n.getMessage("stats_over",
127 (9000).toLocaleString());
128 }
124 129
125 chrome.tabs.create({ 130 chrome.tabs.create({
126 url: createShareLink(ev.target.dataset.social, blockedTotal) 131 url: createShareLink(ev.target.dataset.social, blockedTotal)
127 }); 132 });
128 }); 133 });
129 } 134 }
130 135
131 function toggleIconNumber() 136 function toggleIconNumber()
132 { 137 {
133 togglePref("show_statsinicon", showStatsInIcon => 138 togglePref("show_statsinicon", showStatsInIcon =>
134 { 139 {
135 document.getElementById("show-iconnumber").setAttribute( 140 document.getElementById("show-iconnumber").setAttribute(
136 "aria-checked", showStatsInIcon 141 "aria-checked", showStatsInIcon
137 ); 142 );
138 }); 143 });
139 } 144 }
140 145
141 document.addEventListener("DOMContentLoaded", onLoad, false); 146 document.addEventListener("DOMContentLoaded", onLoad, false);
142 }()); 147 }());
OLDNEW
« no previous file with comments | « lib/utils.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld