Permalink
Browse files

Check whether we’re paused and update the badge on startup

  • Loading branch information...
1 parent ad4d563 commit 2168dcdf5f8daf2fcd1f8ef4193caf4aa4d45f70 Sidney San Martín committed Feb 28, 2012
Showing with 13 additions and 4 deletions.
  1. +13 −4 background.js
View
@@ -1,18 +1,27 @@
+function updateBadge(paused){
+ if (paused){
+ chrome.browserAction.setBadgeText({text:"OFF"});
+ } else {
+ chrome.browserAction.setBadgeText({text:""});
+ }
+}
+
chrome.browserAction.onClicked.addListener(
function(tab){
if (localStorage.getItem('paused')=="yes"){
localStorage.removeItem('paused');
- chrome.browserAction. setBadgeText({text:""});
+ updateBadge(false);
} else {
localStorage.setItem('paused',"yes");
- chrome.browserAction. setBadgeText({text:"OFF"});
+ updateBadge(true);
}
chrome.tabs.update(tab.id, {url: tab.url});
});
-
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
if (request.checkPaused == "hello")
sendResponse({maybePaused: localStorage.getItem('paused')});
- });
+ });
+
+updateBadge(localStorage.getItem('paused')=="yes");

0 comments on commit 2168dcd

Please sign in to comment.