aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorEinar Egilsson <einar@einaregilsson.com>2017-11-22 21:48:05 +0000
committerEinar Egilsson <einar@einaregilsson.com>2017-11-22 21:48:05 +0000
commitdaa74a164f24e3850c30018626547921e7a3f23c (patch)
tree9eb7140b91530d3afc27505c20018a5d3e7c53a5 /js
parent31fc24fdf7220be8147ff8e0e9a8f33af0b43880 (diff)
Logging setting
Diffstat (limited to 'js')
-rw-r--r--js/background.js16
-rw-r--r--js/popup.js14
2 files changed, 28 insertions, 2 deletions
diff --git a/js/background.js b/js/background.js
index c025281..d1a939e 100644
--- a/js/background.js
+++ b/js/background.js
@@ -6,7 +6,7 @@ function log(msg) {
console.log('REDIRECTOR: ' + msg);
}
}
-log.enabled = true;
+log.enabled = false;
//Redirects partitioned by request type, so we have to run through
//the minimum number of redirects for each request.
@@ -120,7 +120,12 @@ function monitorChanges(changes, namespace) {
if (changes.redirects) {
log('Redirects have changed, setting up listener again');
setUpRedirectListener();
- }
+ }
+
+ if (changes.logging) {
+ log('Logging settings have changed, updating...');
+ updateLogging();
+ }
}
chrome.storage.onChanged.addListener(monitorChanges);
@@ -222,6 +227,13 @@ chrome.runtime.onMessage.addListener(
//First time setup
updateIcon();
+function updateLogging() {
+ chrome.storage.local.get({logging:false}, function(obj) {
+ log.enabled = obj.logging;
+ });
+}
+updateLogging();
+
chrome.storage.local.get({disabled:false}, function(obj) {
if (!obj.disabled) {
setUpRedirectListener();
diff --git a/js/popup.js b/js/popup.js
index 0467286..6658fc0 100644
--- a/js/popup.js
+++ b/js/popup.js
@@ -14,6 +14,20 @@ angular.module('popupApp', []).controller('PopupCtrl', ['$scope', function($s) {
$s.disabled = !obj.disabled;
$s.$apply();
});
+ };
+
+
+ storage.get({logging:false}, function(obj) {
+ $s.logging = obj.logging;
+ $s.$apply();
+ });
+
+ $s.toggleLogging = function() {
+ storage.get({logging:false}, function(obj) {
+ storage.set({logging:!obj.logging});
+ $s.logging = !obj.logging;
+ $s.$apply();
+ });
};
$s.openRedirectorSettings = function() {