diff options
author | siikamiika <siikamiika@users.noreply.github.com> | 2017-10-12 01:10:05 +0300 |
---|---|---|
committer | siikamiika <siikamiika@users.noreply.github.com> | 2017-10-12 01:10:05 +0300 |
commit | 4e57fa1ad1cd85e18b2ae2c1d43480832533f9a7 (patch) | |
tree | fc4e9ed7f7c4e5a4dc9ab202a1b03b66620d8b7a | |
parent | 7783aa4c1a36784b709aba768c17d9476a16a43d (diff) |
merged mode: remove options.dictionary.main
-rw-r--r-- | ext/bg/js/options.js | 4 | ||||
-rw-r--r-- | ext/bg/js/settings.js | 4 | ||||
-rw-r--r-- | ext/bg/js/translator.js | 5 |
3 files changed, 3 insertions, 10 deletions
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index 0aa6d7c6..b49c32da 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -154,10 +154,6 @@ function optionsSetDefaults(options) { dictionaries: {}, - dictionary: { - main: '' - }, - anki: { enable: false, server: 'http://127.0.0.1:8765', diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js index cab9c056..6016b38a 100644 --- a/ext/bg/js/settings.js +++ b/ext/bg/js/settings.js @@ -61,9 +61,6 @@ async function formRead() { const priority = parseInt(dictionary.find('.dict-priority').val(), 10); const enabled = dictionary.find('.dict-enabled').prop('checked'); const main = dictionary.find('.dict-main').prop('checked'); - if (main) { - optionsNew.dictionary.main = title; - } optionsNew.dictionaries[title] = {priority, enabled, main}; }); @@ -302,7 +299,6 @@ async function onDictionaryPurge(e) { await utilDatabasePurge(); const options = await optionsLoad(); options.dictionaries = {}; - options.dictionary.main = ''; await optionsSave(options); await dictionaryGroupsPopulate(options); diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index 737abd08..99344b95 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -50,10 +50,11 @@ class Translator { async findTermsMerged(text, dictionaries, alphanumeric) { const options = await apiOptionsGet(); + const mainDictionary = Object.keys(options.dictionaries).filter(dict => options.dictionaries[dict].main).concat([''])[0]; const titles = Object.keys(dictionaries); const {length, definitions} = await this.findTerms(text, dictionaries, alphanumeric); - const definitionsBySequence = dictTermsMergeBySequence(definitions, options.dictionary.main); + const definitionsBySequence = dictTermsMergeBySequence(definitions, mainDictionary); const definitionsMerged = []; const mergedByTermIndices = new Set(); @@ -64,7 +65,7 @@ class Translator { const result = definitionsBySequence[sequence]; - const rawDefinitionsBySequence = await this.database.findTermsBySequence(Number(sequence), options.dictionary.main); + const rawDefinitionsBySequence = await this.database.findTermsBySequence(Number(sequence), mainDictionary); const definitionsByGloss = dictTermsMergeByGloss(result, rawDefinitionsBySequence); dictTermsMergeByGloss(result, definitionsBySequence['-1'], definitionsByGloss, mergedByTermIndices); |