summaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-01-15 22:17:49 -0800
committerAlex Yatskov <alex@foosoft.net>2017-01-15 22:17:49 -0800
commite8840465f07f09fbb9acb6071b94489f02ecd87f (patch)
treea0a4a8bd5ba2783b730e104bbbadd8c1d9975eb7 /ext/bg
parenteae885b9aae58c587e12ec3992b751d79dfc7bd2 (diff)
WIP
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/database.js2
-rw-r--r--ext/bg/js/translator.js14
-rw-r--r--ext/bg/js/yomichan.js14
3 files changed, 13 insertions, 17 deletions
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js
index b74a59a0..7dc533e3 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/database.js
@@ -65,7 +65,7 @@ class Database {
});
}
- findTerm(term, dictionaries) {
+ findTerms(term, dictionaries) {
if (this.db === null) {
return Promise.reject('database not initialized');
}
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index d88aa536..4edf35ac 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -41,12 +41,12 @@ class Translator {
});
}
- findTerm(text, dictionaries, softKatakana) {
+ findTerms(text, dictionaries, softKatakana) {
const cache = {};
- return this.findTermDeinflections(text, dictionaries, cache).then(deinfLiteral => {
+ return this.findTermsDeinflected(text, dictionaries, cache).then(deinfLiteral => {
const textHiragana = wanakana._katakanaToHiragana(text);
if (text !== textHiragana && softKatakana) {
- return this.findTermDeinflections(textHiragana, dictionaries, cache).then(deinfHiragana => deinfLiteral.concat(deinfHiragana));
+ return this.findTermsDeinflected(textHiragana, dictionaries, cache).then(deinfHiragana => deinfLiteral.concat(deinfHiragana));
} else {
return deinfLiteral;
}
@@ -82,8 +82,8 @@ class Translator {
});
}
- findTermGrouped(text, dictionaries, softKatakana) {
- return this.findTerm(text, dictionaries, softKatakana).then(({length, definitions}) => {
+ findTermsGrouped(text, dictionaries, softKatakana) {
+ return this.findTerms(text, dictionaries, softKatakana).then(({length, definitions}) => {
return {length, definitions: groupTermDefs(definitions)};
});
}
@@ -109,13 +109,13 @@ class Translator {
});
}
- findTermDeinflections(text, dictionaries, cache) {
+ findTermsDeinflected(text, dictionaries, cache) {
const definer = term => {
if (cache.hasOwnProperty(term)) {
return Promise.resolve(cache[term]);
}
- return this.database.findTerm(term, dictionaries).then(definitions => cache[term] = definitions);
+ return this.database.findTerms(term, dictionaries).then(definitions => cache[term] = definitions);
};
const promises = [];
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index 67b1606c..27077f57 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -106,15 +106,11 @@ class Yomichan {
tabInvokeAll(action, params) {
chrome.tabs.query({}, tabs => {
for (const tab of tabs) {
- this.tabInvoke(tab.id, action, params);
+ chrome.tabs.sendMessage(tab.id, {action, params}, () => null);
}
});
}
- tabInvoke(tabId, action, params) {
- chrome.tabs.sendMessage(tabId, {action, params}, () => null);
- }
-
formatNote(definition, mode) {
const note = {fields: {}, tags: this.options.anki.tags};
@@ -174,7 +170,7 @@ class Yomichan {
);
}
- api_findTerm({text, callback}) {
+ api_findTerms({text, callback}) {
const dictionaries = [];
for (const title in this.options.dictionaries) {
if (this.options.dictionaries[title].enableTerms) {
@@ -183,7 +179,7 @@ class Yomichan {
}
promiseCallback(
- this.translator.findTerm(
+ this.translator.findTerms(
text,
dictionaries,
this.options.general.softKatakana
@@ -192,7 +188,7 @@ class Yomichan {
);
}
- api_findTermGrouped({text, callback}) {
+ api_findTermsGrouped({text, callback}) {
const dictionaries = [];
for (const title in this.options.dictionaries) {
if (this.options.dictionaries[title].enableTerms) {
@@ -201,7 +197,7 @@ class Yomichan {
}
promiseCallback(
- this.translator.findTermGrouped(
+ this.translator.findTermsGrouped(
text,
dictionaries,
this.options.general.softKatakana