Index: stats.js |
diff --git a/stats.js b/stats.js |
index 416f0bbafd0edaf86b6fdf4f71aefd7208c55d5a..141ab72ce359320d3511f48781443f9e6675b7cc 100644 |
--- a/stats.js |
+++ b/stats.js |
@@ -15,19 +15,21 @@ |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
-(function() |
+"use strict"; |
+ |
{ |
- var backgroundPage = ext.backgroundPage.getWindow(); |
- var require = backgroundPage.require; |
- var getBlockedPerPage = require("stats").getBlockedPerPage; |
- var FilterNotifier = require("filterNotifier").FilterNotifier; |
- var Prefs = require("prefs").Prefs; |
+ const backgroundPage = ext.backgroundPage.getWindow(); |
+ const {require} = backgroundPage; |
Sebastian Noack
2017/01/18 11:24:30
Note that backgroundPage isn't used anywhere else,
kzar
2017/01/18 11:46:40
Done.
|
+ |
+ const {getBlockedPerPage} = require("stats"); |
+ const {FilterNotifier} = require("filterNotifier"); |
+ const {Prefs} = require("prefs"); |
- var currentPage; |
- var shareURL = "https://adblockplus.org/"; |
+ let currentPage; |
+ const shareURL = "https://adblockplus.org/"; |
- var messageMark = {}; |
- var shareLinks = { |
+ let messageMark = {}; |
+ let shareLinks = { |
facebook: ["https://www.facebook.com/dialog/feed", { |
app_id: "475542399197328", |
link: shareURL, |
@@ -53,13 +55,13 @@ |
function createShareLink(network, blockedCount) |
{ |
- var url = shareLinks[network][0]; |
- var params = shareLinks[network][1]; |
+ let url = shareLinks[network][0]; |
+ let params = shareLinks[network][1]; |
- var querystring = []; |
- for (var key in params) |
+ let querystring = []; |
+ for (let key in params) |
{ |
- var value = params[key]; |
+ let value = params[key]; |
if (value == messageMark) |
value = i18n.getMessage("stats_share_message", blockedCount); |
querystring.push(encodeURIComponent(key) + "=" + encodeURIComponent(value)); |
@@ -70,13 +72,13 @@ |
function onLoad() |
{ |
document.getElementById("share-box").addEventListener("click", share, false); |
- var showIconNumber = document.getElementById("show-iconnumber"); |
+ let showIconNumber = document.getElementById("show-iconnumber"); |
showIconNumber.setAttribute("aria-checked", Prefs.show_statsinicon); |
showIconNumber.addEventListener("click", toggleIconNumber, false); |
document.querySelector("label[for='show-iconnumber']").addEventListener("click", toggleIconNumber, false); |
// Update stats |
- ext.pages.query({active: true, lastFocusedWindow: true}, function(pages) |
+ ext.pages.query({active: true, lastFocusedWindow: true}, pages => |
{ |
currentPage = pages[0]; |
updateStats(); |
@@ -94,19 +96,19 @@ |
function updateStats() |
{ |
- var statsPage = document.getElementById("stats-page"); |
- var blockedPage = getBlockedPerPage(currentPage).toLocaleString(); |
+ let statsPage = document.getElementById("stats-page"); |
+ let blockedPage = getBlockedPerPage(currentPage).toLocaleString(); |
i18n.setElementText(statsPage, "stats_label_page", [blockedPage]); |
- var statsTotal = document.getElementById("stats-total"); |
- var blockedTotal = Prefs.blocked_total.toLocaleString(); |
+ let statsTotal = document.getElementById("stats-total"); |
+ let blockedTotal = Prefs.blocked_total.toLocaleString(); |
i18n.setElementText(statsTotal, "stats_label_total", [blockedTotal]); |
} |
function share(ev) |
{ |
// Easter Egg |
- var blocked = Prefs.blocked_total; |
+ let blocked = Prefs.blocked_total; |
if (blocked <= 9000 || blocked >= 10000) |
blocked = blocked.toLocaleString(); |
else |
@@ -123,4 +125,4 @@ |
document.addEventListener("DOMContentLoaded", onLoad, false); |
window.addEventListener("unload", onUnload, false); |
-})(); |
+} |