summaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/generic-setting-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/settings/generic-setting-controller.js')
-rw-r--r--ext/bg/js/settings/generic-setting-controller.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/ext/bg/js/settings/generic-setting-controller.js b/ext/bg/js/settings/generic-setting-controller.js
index 04cad67d..b669cab9 100644
--- a/ext/bg/js/settings/generic-setting-controller.js
+++ b/ext/bg/js/settings/generic-setting-controller.js
@@ -36,7 +36,8 @@ class GenericSettingController {
['splitTags', this._splitTags.bind(this)],
['joinTags', this._joinTags.bind(this)],
['toNumber', this._toNumber.bind(this)],
- ['toString', this._toString.bind(this)]
+ ['toString', this._toString.bind(this)],
+ ['conditionalConvert', this._conditionalConvert.bind(this)]
]);
}
@@ -208,4 +209,19 @@ class GenericSettingController {
_toString(value) {
return `${value}`;
}
+
+ _conditionalConvert(value, data) {
+ const {cases} = data;
+ if (Array.isArray(cases)) {
+ for (const {op, value: value2, default: isDefault, result} of cases) {
+ if (isDefault === true) {
+ value = result;
+ } else if (this._evaluateSimpleOperation(op, value, value2)) {
+ value = result;
+ break;
+ }
+ }
+ }
+ return value;
+ }
}