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 @@ -
+ +