summaryrefslogtreecommitdiff
path: root/ext/bg/js/dictionary.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-09-13 20:36:13 -0700
committerAlex Yatskov <alex@foosoft.net>2016-09-13 20:36:13 -0700
commit17366e521afe2dd3b32f2068db43f972ce89b36f (patch)
tree94a1a2c37e8187ecc2484be79b6d5d032344b648 /ext/bg/js/dictionary.js
parent0e89d0e7e68d58407480e0e40e80c2f00f3c2f66 (diff)
Progress callback for dictionary loading
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r--ext/bg/js/dictionary.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index 936dc3c1..2bd39344 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -130,7 +130,7 @@ class Dictionary {
});
}
- importTermDict(indexUrl) {
+ importTermDict(indexUrl, callback) {
if (this.db === null) {
return Promise.reject('database not initialized');
}
@@ -161,7 +161,11 @@ class Dictionary {
rows.push({expression, reading, tags, glossary});
}
- return this.db.terms.bulkAdd(rows);
+ return this.db.terms.bulkAdd(rows).then(() => {
+ if (callback) {
+ callback(i, index.banks);
+ }
+ });
});
});
}
@@ -176,7 +180,7 @@ class Dictionary {
});
}
- importKanjiDict(indexUrl) {
+ importKanjiDict(indexUrl, callback) {
if (this.db === null) {
return Promise.reject('database not initialized');
}
@@ -193,7 +197,11 @@ class Dictionary {
rows.push({character, onyomi, kunyomi, tags, meanings});
}
- return this.db.kanji.bulkAdd(rows);
+ return this.db.kanji.bulkAdd(rows).then(() => {
+ if (callback) {
+ callback(i, index.banks);
+ }
+ });
});
});
}