From 71ec21e871ada80dddb1f2c48cc40f1fe07913d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20R=C3=B6bert?= Date: Tue, 19 Jun 2018 18:13:44 +0200 Subject: [PATCH] Version 1.3.2.0 + Fix a problem with the badged_color settings + Message for Incognito mode + Suggestion #65 implemented --- core_js/popup_new.js | 70 +++++++++++++++++++++++++++++++++++++------- core_js/settings.js | 2 ++ html/popup.html | 19 +++++++++--- manifest.json | 2 +- 4 files changed, 78 insertions(+), 15 deletions(-) diff --git a/core_js/popup_new.js b/core_js/popup_new.js index 271ab2e..3b08b56 100644 --- a/core_js/popup_new.js +++ b/core_js/popup_new.js @@ -86,16 +86,52 @@ function changeSwitchButton(id, storageID) { var element = $('#'+id); + changeVisibility(id, storageID); + element.on('change', function(){ core(function (ref){ ref.setData(storageID, element.is(':checked')); if(storageID == "globalStatus") ref.changeIcon(); + changeVisibility(id, storageID); ref.saveOnExit(); }); }); } +/** + * Change the visibility of sections. + */ +function changeVisibility(id, storageID) +{ + var element; + + switch(storageID) + { + case "loggingStatus": + element = $('#log_section'); + break; + case "statisticsStatus": + element = $('#statistic_section'); + break; + default: + element = "undefine"; + } + + if(element != "undefine") + { + if($('#'+id).is(':checked')) + { + element.css('display', ''); + element.css('display', ''); + } + else { + element.css('display', 'none'); + element.css('display', 'none'); + } + } +} + /** * Set the value of a switch button. * @param {string} id HTML id @@ -122,17 +158,31 @@ function resetGlobalCounter(){ }); } -getData(); +if(!browser.extension.inIncognitoContext) +{ + getData(); +} + $(document).ready(function(){ - init(); - $('#reset_counter_btn').on("click", resetGlobalCounter); - changeSwitchButton("globalStatus", "globalStatus"); - changeSwitchButton("tabcounter", "badgedStatus"); - changeSwitchButton("logging", "loggingStatus"); - changeSwitchButton("statistics", "statisticsStatus"); - $('#loggingPage').attr('href', browser.extension.getURL('./html/log.html')); - $('#settings').attr('href', browser.extension.getURL('./html/settings.html')); - setText(); + if(!browser.extension.inIncognitoContext) + { + init(); + $('#reset_counter_btn').on("click", resetGlobalCounter); + changeSwitchButton("globalStatus", "globalStatus"); + changeSwitchButton("tabcounter", "badgedStatus"); + changeSwitchButton("logging", "loggingStatus"); + changeSwitchButton("statistics", "statisticsStatus"); + $('#loggingPage').attr('href', browser.extension.getURL('./html/log.html')); + $('#settings').attr('href', browser.extension.getURL('./html/settings.html')); + setText(); + } else { + $('#config_section').remove(); + $('#statistic_section').remove(); + $('#status_section').remove(); + $('#log_section').remove(); + $('#incognito').css('display', ''); + } + }); /** diff --git a/core_js/settings.js b/core_js/settings.js index 857b618..7f8b785 100644 --- a/core_js/settings.js +++ b/core_js/settings.js @@ -45,6 +45,8 @@ function save() { core(function (ref){ + ref.setData('badged_color', $('input[name=badged_color]').val()); + ref.setBadgedStatus(); ref.setData('ruleURL', $('input[name=rule_url]').val()); ref.setData('hashURL', $('input[name=hash_url]').val()); ref.saveOnExit(); diff --git a/html/popup.html b/html/popup.html index 596c3ac..39eeb25 100644 --- a/html/popup.html +++ b/html/popup.html @@ -32,7 +32,18 @@ -
+ + +
@@ -64,7 +75,7 @@
-
+
@@ -106,7 +117,7 @@
-
+
@@ -118,7 +129,7 @@

-
+