diff options
Diffstat (limited to 'js/popup.js')
-rw-r--r-- | js/popup.js | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/js/popup.js b/js/popup.js index fbff178..9aa13cf 100644 --- a/js/popup.js +++ b/js/popup.js @@ -1,13 +1,34 @@ -function hi() { - chrome.browserAction.setIcon({ - path: { - 19: "images/icon19disabled.png", - 38: "images/icon38disabled.png" - } - }); - open('redirector.html'); -} - -document.addEventListener('DOMContentLoaded', function() { - document.getElementsByTagName('button')[0].addEventListener('click', hi); -})
\ No newline at end of file + +angular.module('popupApp', []).controller('PopupCtrl', ['$scope', function($s) { + + var storage = chrome.storage.local; //TODO: Change to sync when Firefox supports it... + + storage.get({disabled:false}, function(obj) { + $s.disabled = obj.disabled; + $s.$apply(); + }); + + $s.toggleDisabled = function() { + storage.get({disabled:false}, function(obj) { + storage.set({disabled:!obj.disabled}); + $s.disabled = !obj.disabled; + $s.$apply(); + }); + }; + + $s.openRedirectorSettings = function() { + + //switch to open one if we have it to minimize conflicts + var url = chrome.extension.getURL('redirector.html'); + + chrome.tabs.query({currentWindow:true, url:url}, function(tabs) { + if (tabs.length > 0) { + chrome.tabs.update(tabs[0].id, {active:true}, function(tab) { + close(); + }); + } else { + open(url); + } + }); + }; +}]);
\ No newline at end of file |