diff options
author | Alex Yatskov <FooSoft@users.noreply.github.com> | 2019-11-13 18:51:50 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-13 18:51:50 -0800 |
commit | b1659522b30cecc0583745da5a44fdd75660274a (patch) | |
tree | 89c17fa51f91ee43b1a206a9ae2d7b5721892ae9 /ext/bg/js/api.js | |
parent | 7d9d45ae10302582ce7431bd72ec4f8604dc5e65 (diff) | |
parent | 7333873244ccaeeefe01bd3a63447f39dd4f3bbe (diff) |
Merge pull request #274 from toasted-nutbread/lookup-wildcards
Lookup wildcards
Diffstat (limited to 'ext/bg/js/api.js')
-rw-r--r-- | ext/bg/js/api.js | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js index 9fed99a1..df73aa2a 100644 --- a/ext/bg/js/api.js +++ b/ext/bg/js/api.js @@ -72,33 +72,18 @@ async function apiOptionsSave(source) { backend.onOptionsUpdated(source); } -async function apiTermsFind(text, optionsContext) { +async function apiTermsFind(text, details, optionsContext) { const options = await apiOptionsGet(optionsContext); - const translator = utilBackend().translator; - - const searcher = { - 'merge': translator.findTermsMerged, - 'split': translator.findTermsSplit, - 'group': translator.findTermsGrouped - }[options.general.resultOutputMode].bind(translator); - - const {definitions, length} = await searcher( - text, - dictEnabledSet(options), - options.scanning.alphanumeric, - options - ); - - return { - length, - definitions: definitions.slice(0, options.general.maxResults) - }; + const [definitions, length] = await utilBackend().translator.findTerms(text, details, options); + definitions.splice(options.general.maxResults); + return {length, definitions}; } async function apiKanjiFind(text, optionsContext) { const options = await apiOptionsGet(optionsContext); - const definitions = await utilBackend().translator.findKanji(text, dictEnabledSet(options)); - return definitions.slice(0, options.general.maxResults); + const definitions = await utilBackend().translator.findKanji(text, options); + definitions.splice(options.general.maxResults); + return definitions; } async function apiDefinitionAdd(definition, mode, context, optionsContext) { |