aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgorhill <rhill@raymondhill.net>2015-04-07 13:27:46 -0400
committergorhill <rhill@raymondhill.net>2015-04-07 13:27:46 -0400
commitaa8b5850b812813ccad863b3712fa0796639cb54 (patch)
tree68e0cded87d51239c2c00ccef2f8e8c4cc493db6
parentc6668391e06f6d3fba009a5dcdda8ab9265bdd01 (diff)
downloaduBlock-aa8b5850b812813ccad863b3712fa0796639cb54.zip
uBlock-aa8b5850b812813ccad863b3712fa0796639cb54.tar.gz
uBlock-aa8b5850b812813ccad863b3712fa0796639cb54.tar.bz2
code review
-rw-r--r--src/js/hnswitches.js9
-rw-r--r--src/js/ublock.js10
2 files changed, 10 insertions, 9 deletions
diff --git a/src/js/hnswitches.js b/src/js/hnswitches.js
index 1ca46b3..392cda0 100644
--- a/src/js/hnswitches.js
+++ b/src/js/hnswitches.js
@@ -196,6 +196,15 @@ HnSwitches.prototype.toggleBranchZ = function(switchName, targetHostname, newSta
/******************************************************************************/
+HnSwitches.prototype.toggleZ = function(switchName, hostname, deep, newState) {
+ if ( deep === true ) {
+ return this.hnSwitches.toggleBranchZ(switchName, hostname, newState);
+ }
+ return this.hnSwitches.toggleOneZ(switchName, hostname, newState);
+};
+
+/******************************************************************************/
+
// 0 = inherit from broader scope, up to default state
// 1 = non-default state
// 2 = forced default state (to override a broader non-default state)
diff --git a/src/js/ublock.js b/src/js/ublock.js
index 329724e..e1b259e 100644
--- a/src/js/ublock.js
+++ b/src/js/ublock.js
@@ -319,15 +319,7 @@ var matchWhitelistDirective = function(url, hostname, directive) {
/******************************************************************************/
µBlock.toggleHostnameSwitch = function(details) {
- var changed = false;
-
- if ( details.deep === true ) {
- changed = this.hnSwitches.toggleBranchZ(details.name, details.hostname, details.state);
- } else {
- changed = this.hnSwitches.toggleOneZ(details.name, details.hostname, details.state);
- }
-
- if ( changed ) {
+ if ( this.hnSwitches.toggleZ(details.name, details.hostname, !!details.deep, details.state) ) {
this.saveHostnameSwitches();
}