summaryrefslogtreecommitdiff
path: root/ext/bg/js/dictionary.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-08-21 13:32:36 -0700
committerAlex Yatskov <alex@foosoft.net>2016-08-21 13:32:36 -0700
commit67f906ab24acb80a8ffbad29ff8ddda5fc570cf0 (patch)
tree119358264dd2de12d0af016f4fe97bb683e2be43 /ext/bg/js/dictionary.js
parent96c6c4ad1ae8dd784ba4d90546ae3bf7ce1861f6 (diff)
Import stubs
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r--ext/bg/js/dictionary.js20
1 files changed, 16 insertions, 4 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index a6438523..082d1479 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -21,20 +21,32 @@ class Dictionary {
constructor() {
this.termDicts = {};
this.kanjiDicts = {};
+ this.db = new Dexie('dict');
+ this.dbVer = 1;
}
- addTermDict(name, dict) {
+ loadDb() {
+ return this.db.open().then((db) => {
+ if (db.verno !== this.dbVer) {
+ Promise.reject('db version mismatch');
+ }
+
+ return db.verno;
+ });
+ }
+
+ importTermDict(name, dict) {
this.termDicts[name] = dict;
}
- addKanjiDict(name, dict) {
+ importKanjiDict(name, dict) {
this.kanjiDicts[name] = dict;
}
findTerm(term) {
let results = [];
- for (let name in this.termDicts) {
+ for (const name in this.termDicts) {
const dict = this.termDicts[name];
if (!(term in dict.i)) {
continue;
@@ -62,7 +74,7 @@ class Dictionary {
findKanji(kanji) {
const results = [];
- for (let name in this.kanjiDicts) {
+ for (const name in this.kanjiDicts) {
const def = this.kanjiDicts[name].c[kanji];
if (def) {
const [k, o, t, ...g] = def;