diff options
author | Alex Yatskov <alex@foosoft.net> | 2016-11-05 17:51:01 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2016-11-05 17:51:01 -0700 |
commit | d3a01738740c9a38011e5b98b3f37709bea515e1 (patch) | |
tree | 7d41e721925dce371d2a7f2afe50e0b1cafc3aec /ext/bg/js/dictionary.js | |
parent | e2f1560afa25274d3b0efd3ce8fc8a17740ab7cc (diff) |
Dictionary naming
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r-- | ext/bg/js/dictionary.js | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index a2a4047a..936f3dd8 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -33,7 +33,9 @@ class Dictionary { this.db.version(1).stores({ terms: '++id, dictionary, expression, reading', kanji: '++, dictionary, character', - entities: '++, dictionary, name', + entities: '++, dictionary', + termDicts: '++, dictionary', + kanjiDicts: '++, dictionary, version', meta: 'name, value', }); } @@ -135,22 +137,24 @@ class Dictionary { return Promise.reject('database not initialized'); } - const indexLoaded = (dictionary, entities) => { - this.entities = entities || {}; - - const rows = []; - for (const name in entities || {}) { - rows.push({ - dictionary, - name, - value: entities[name] - }); - } + const indexLoaded = (dictionary, version, entities) => { + return this.db.termDicts.add({dictionary, version}).then(() => { + this.entities = entities || {}; + + const rows = []; + for (const name in entities || {}) { + rows.push({ + dictionary, + name, + value: entities[name] + }); + } - return this.db.entities.bulkAdd(rows); + return this.db.entities.bulkAdd(rows); + }); }; - const entriesLoaded = (dictionary, entries, total, current) => { + const entriesLoaded = (dictionary, version, entries, total, current) => { const rows = []; for (const [expression, reading, tags, ...glossary] of entries) { rows.push({ @@ -177,7 +181,11 @@ class Dictionary { return Promise.reject('database not initialized'); } - const entriesLoaded = (dictionary, entries, total, current) => { + const indexLoaded = (dictionary, version) => { + return this.db.kanjiDicts.add({dictionary, version}); + }; + + const entriesLoaded = (dictionary, version, entries, total, current) => { const rows = []; for (const [character, onyomi, kunyomi, tags, ...meanings] of entries) { rows.push({ |