diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-12-31 13:38:51 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-31 13:38:51 -0500 |
commit | 1b4ba1fb006a6e6dda7f19c797b204c43900df4a (patch) | |
tree | cd1529f5c2b448ef2d2f9673b20435c94b91f44a /ext/bg/js | |
parent | 1ac4e979e49cf65fbda1ad8f9a92b22b5b22bccf (diff) |
Simplify glossary layout setting (#1188)
* Add conditionalConvert transform
* Convert glossaryLayoutMode option to a toggle
Diffstat (limited to 'ext/bg/js')
-rw-r--r-- | ext/bg/js/settings/generic-setting-controller.js | 18 |
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; + } } |