summaryrefslogtreecommitdiff
path: root/ext/bg/js/dictionary.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-11-06 11:01:35 -0800
committerAlex Yatskov <alex@foosoft.net>2016-11-06 11:01:35 -0800
commit3f606a0ab00a084e7f22b232cdd5a7006ab7d636 (patch)
tree986300aaccef69f137a6395aa9dcc9b86798012d /ext/bg/js/dictionary.js
parent84fd2d13f5d0f7321d0aa708902dd94cdbd3bac8 (diff)
Combined import
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r--ext/bg/js/dictionary.js28
1 files changed, 8 insertions, 20 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index aa5f0b47..5859350b 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -20,7 +20,7 @@
class Dictionary {
constructor() {
this.db = null;
- this.dbVer = 4;
+ this.dbVer = 5;
this.entities = null;
}
@@ -131,7 +131,7 @@ class Dictionary {
});
}
- getDictionaries() {
+ getNames() {
if (this.db === null) {
return Promise.reject('database not initialized');
}
@@ -139,7 +139,7 @@ class Dictionary {
return this.db.dictionaries.toArray();
}
- importTermDict(indexUrl, callback) {
+ importDb(indexUrl, callback) {
if (this.db === null) {
return Promise.reject('database not initialized');
}
@@ -161,7 +161,7 @@ class Dictionary {
});
};
- const entriesLoaded = (dictionary, version, entries, total, current) => {
+ const termsLoaded = (dictionary, version, entries, total, current) => {
const rows = [];
for (const [expression, reading, tags, ...glossary] of entries) {
rows.push({
@@ -175,24 +175,12 @@ class Dictionary {
return this.db.terms.bulkAdd(rows).then(() => {
if (callback) {
- callback(current, total, indexUrl);
+ callback(total, current, indexUrl);
}
});
};
- return importJsonDb(indexUrl, indexLoaded, entriesLoaded);
- }
-
- importKanjiDict(indexUrl, callback) {
- if (this.db === null) {
- return Promise.reject('database not initialized');
- }
-
- const indexLoaded = (dictionary, version) => {
- return this.db.dictionaries.add({dictionary, version});
- };
-
- const entriesLoaded = (dictionary, version, entries, total, current) => {
+ const kanjiLoaded = (dictionary, version, entries, total, current) => {
const rows = [];
for (const [character, onyomi, kunyomi, tags, ...meanings] of entries) {
rows.push({
@@ -207,11 +195,11 @@ class Dictionary {
return this.db.kanji.bulkAdd(rows).then(() => {
if (callback) {
- callback(current, total, indexUrl);
+ callback(total, current, indexUrl);
}
});
};
- return importJsonDb(indexUrl, indexLoaded, entriesLoaded);
+ return importJsonDb(indexUrl, indexLoaded, termsLoaded, kanjiLoaded);
}
}