aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/dictionary.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-04-17 18:38:29 -0700
committerAlex Yatskov <alex@foosoft.net>2016-04-17 18:38:29 -0700
commit5bebf3ed2cff5c460afe6f0d3df56f26f12ae240 (patch)
treeb1e4d30eac7ca150fb1a0e38287b7b488869644f /ext/bg/js/dictionary.js
parent52a8e2207c70573abd1e47cc8d019ba9e592a9dd (diff)
Revert "Support switching between edict and enamdict"
This reverts commit f079db0471424a873f22315c7911571d467e97ad.
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r--ext/bg/js/dictionary.js39
1 files changed, 25 insertions, 14 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index b91e53bf..6870601e 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -31,24 +31,35 @@ class Dictionary {
this.kanjiDicts[name] = dict;
}
- findTerm(term, dict) {
- const db = this.termDicts[dict];
- const indices = db.indices[term] || [];
-
- return indices.map(index => {
- const [e, r, t, ...g] = db.defs[index];
- return {id: index, expression: e, reading: r, glossary: g, tags: t.split(' ')};
- });
+ findTerm(term) {
+ let results = [];
+
+ for (const name in this.termDicts) {
+ const dict = this.termDicts[name];
+ const indices = dict.indices[term] || [];
+
+ results = results.concat(
+ indices.map(index => {
+ const [e, r, t, ...g] = dict.defs[index];
+ return {id: index, expression: e, reading: r, glossary: g, tags: t.split(' ')};
+ })
+ );
+ }
+
+ return results;
}
- findKanji(kanji, dict) {
- const def = this.termDicts[dict][kanji];
+ findKanji(kanji) {
+ const results = [];
- if (def) {
- const [c, k, o, g] = def;
- return {id: index, character: c, kunyomi: k, onyomi: o, glossary: g};
+ for (const name in this.termDicts) {
+ const def = this.termDicts[name][kanji];
+ if (def) {
+ const [c, k, o, g] = def;
+ results.push({id: index, character: c, kunyomi: k, onyomi: o, glossary: g});
+ }
}
- return null;
+ return results;
}
}