summaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/translator.js6
-rw-r--r--ext/bg/js/util.js2
-rw-r--r--ext/bg/js/yomichan.js24
3 files changed, 30 insertions, 2 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index bdd606b7..8710f568 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -82,6 +82,12 @@ class Translator {
});
}
+ findTermGrouped(text, dictionaries, enableSoftKatakanaSearch) {
+ return this.findTerm(text, dictionaries, enableSoftKatakanaSearch).then(({length, definitions}) => {
+ return {length, definitions: groupTermDefs(definitions)};
+ });
+ }
+
findKanji(text, dictionaries) {
const processed = {}, promises = [];
for (const c of text) {
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js
index 3fa01a10..19d08a7c 100644
--- a/ext/bg/js/util.js
+++ b/ext/bg/js/util.js
@@ -116,7 +116,7 @@ function groupTermDefs(definitions) {
const tagCounts = {};
for (const tag of groupDefs.map(def => def.tags)) {
- const count = tagsGlobal[tag.name] || 0;
+ const count = tagCounts[tag.name] || 0;
tagCounts[tag.name] = count + 1;
}
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index 69397a61..f96e4437 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -188,7 +188,29 @@ class Yomichan {
}
promiseCallback(
- this.translator.findTerm(text, dictionaries, this.options.enableSoftKatakanaSearch),
+ this.translator.findTerm(
+ text,
+ dictionaries,
+ this.options.enableSoftKatakanaSearch
+ ),
+ callback
+ );
+ }
+
+ api_findTermGrouped({text, callback}) {
+ const dictionaries = [];
+ for (const title in this.options.dictionaries) {
+ if (this.options.dictionaries[title].enableTerms) {
+ dictionaries.push(title);
+ }
+ }
+
+ promiseCallback(
+ this.translator.findTermGrouped(
+ text,
+ dictionaries,
+ this.options.enableSoftKatakanaSearch
+ ),
callback
);
}