diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-04-03 13:02:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-03 13:02:49 -0400 |
commit | a9fe2d03b22a0dd5760019f1325a7a86ebb07b85 (patch) | |
tree | aa2fe04c741c82c0456f44a39139c52988b6c22d /ext/js/pages/settings/secondary-search-dictionary-controller.js | |
parent | 0d2d342cd373798e3daf42799a9f35d974db92f5 (diff) |
Update dictionary settings structure (#1587)
* Update dictionary settings structure to use an array instead of an object
* Update ensureDictionarySettings implementation
* Remove some usage of ObjectPropertyAccessor
Diffstat (limited to 'ext/js/pages/settings/secondary-search-dictionary-controller.js')
-rw-r--r-- | ext/js/pages/settings/secondary-search-dictionary-controller.js | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/ext/js/pages/settings/secondary-search-dictionary-controller.js b/ext/js/pages/settings/secondary-search-dictionary-controller.js index 13e1dcf5..8ffd9a9b 100644 --- a/ext/js/pages/settings/secondary-search-dictionary-controller.js +++ b/ext/js/pages/settings/secondary-search-dictionary-controller.js @@ -15,10 +15,6 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* global - * ObjectPropertyAccessor - */ - class SecondarySearchDictionaryController { constructor(settingsController) { this._settingsController = settingsController; @@ -60,21 +56,23 @@ class SecondarySearchDictionaryController { const fragment = document.createDocumentFragment(); - for (const dictionary of Object.keys(options.dictionaries)) { - const dictionaryInfo = this._dictionaryInfoMap.get(dictionary); + const {dictionaries} = options; + for (let i = 0, ii = dictionaries.length; i < ii; ++i) { + const {name} = dictionaries[i]; + const dictionaryInfo = this._dictionaryInfoMap.get(name); if (typeof dictionaryInfo === 'undefined') { continue; } const node = this._settingsController.instantiateTemplate('secondary-search-dictionary'); fragment.appendChild(node); const nameNode = node.querySelector('.dictionary-title'); - nameNode.textContent = dictionary; + nameNode.textContent = name; const versionNode = node.querySelector('.dictionary-version'); versionNode.textContent = `rev.${dictionaryInfo.revision}`; const toggle = node.querySelector('.dictionary-allow-secondary-searches'); - toggle.dataset.setting = ObjectPropertyAccessor.getPathString(['dictionaries', dictionary, 'allowSecondarySearches']); + toggle.dataset.setting = `dictionaries[${i}].allowSecondarySearches`; this._eventListeners.addEventListener(toggle, 'settingChanged', this._onEnabledChanged.bind(this, node), false); } |