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

Unified Diff: stats.js

Issue 16067002: Added Safari Support (Closed)
Patch Set: Adressed comments Created Nov. 13, 2013, 3:11 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « safari/content.js ('k') | utils.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: stats.js
===================================================================
--- a/stats.js
+++ b/stats.js
@@ -17,12 +17,12 @@
(function()
{
- var backgroundPage = chrome.extension.getBackgroundPage();
+ var backgroundPage = ext.backgroundPage.getWindow();
var require = backgroundPage.require;
var getStats = require("stats").getStats;
var FilterNotifier = require("filterNotifier").FilterNotifier;
- var currentTabId;
+ var currentTab;
var shareURL = "https://adblockplus.org/";
var messageMark = {};
@@ -72,20 +72,17 @@
document.getElementById("share").addEventListener("click", toggleShareBox, false);
// Update stats
- chrome.tabs.query({
- active: true,
- windowId: chrome.windows.WINDOW_ID_CURRENT
- }, function(tabs)
+ ext.windows.getLastFocused(function(win)
{
- if (tabs.length > 0)
+ win.getActiveTab(function(tab)
{
- currentTabId = tabs[0].id;
+ currentTab = tab;
updateStats();
-
+
FilterNotifier.addListener(onNotify);
-
+
document.getElementById("statsContainer").removeAttribute("hidden");
- }
+ });
});
}
@@ -103,7 +100,7 @@
function updateStats()
{
var statsPage = document.getElementById("statsPage");
- var blockedPage = getStats("blocked", currentTabId).toLocaleString();
+ var blockedPage = getStats("blocked", currentTab).toLocaleString();
i18n.setElementText(statsPage, "stats_label_page", [blockedPage]);
var statsTotal = document.getElementById("statsTotal");
@@ -127,7 +124,7 @@
blocked = i18n.getMessage("stats_over", (9000).toLocaleString());
var url = createShareLink(ev.target.dataset.social, blocked);
- chrome.tabs.create({url: url});
+ ext.windows.getLastFocused(function(win) { win.openTab(url); });
}
document.addEventListener("DOMContentLoaded", onLoad, false);
« no previous file with comments | « safari/content.js ('k') | utils.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld