summaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/dictionary.js11
-rw-r--r--ext/bg/js/translator.js16
2 files changed, 10 insertions, 17 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index 4baa41c8..b7b7039c 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -28,21 +28,14 @@ class Dictionary {
}
initDb() {
+ this.entities = null;
+
this.db = new Dexie('dict');
this.db.version(1).stores({
terms: '++id,expression,reading',
entities: '++,name',
kanji: '++,character'
});
-
- return this.db;
- }
-
- loadDb() {
- this.db = null;
- this.entities = null;
-
- return this.initDb().open();
}
findTerm(term) {
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index d1a92d08..f7dfae13 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -38,16 +38,16 @@ class Translator {
this.tagMeta = tagMeta;
return this.dictionary.existsDb();
}).then((exists) => {
+ this.dictionary.initDb();
if (exists) {
- return this.dictionary.loadDb();
- } else {
- this.dictionary.initDb();
- return Promise.all([
- this.dictionary.importKanjiDict('bg/data/kanjidic/index.json'),
- this.dictionary.importTermDict('bg/data/edict/index.json'),
- this.dictionary.importTermDict('bg/data/enamdict/index.json')
- ]);
+ return Promise.resolve();
}
+
+ return Promise.all([
+ this.dictionary.importKanjiDict('bg/data/kanjidic/index.json'),
+ this.dictionary.importTermDict('bg/data/edict/index.json'),
+ this.dictionary.importTermDict('bg/data/enamdict/index.json')
+ ]);
}).then(() => {
this.dictionary.findTerm('猫').then((result) => {
console.log(result);