summaryrefslogtreecommitdiff
path: root/ext/bg/js/util.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-07-10 14:53:06 -0700
committerAlex Yatskov <alex@foosoft.net>2017-07-10 14:53:06 -0700
commitf694026827ab2ce3a884206f7494b98335137709 (patch)
tree720b7d897751328cdc4ecdfe3692c30016cbe450 /ext/bg/js/util.js
parent49352c5fa1baea4a6ed7d71d1353c13a56b00bca (diff)
move zip import to async
Diffstat (limited to 'ext/bg/js/util.js')
-rw-r--r--ext/bg/js/util.js64
1 files changed, 0 insertions, 64 deletions
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js
index b39b4b2f..1954e83b 100644
--- a/ext/bg/js/util.js
+++ b/ext/bg/js/util.js
@@ -456,70 +456,6 @@ function jsonLoadInt(url) {
}
/*
- * Zip
- */
-
-function zipLoadDb(archive, indexLoaded, termsLoaded, kanjiLoaded) {
- return JSZip.loadAsync(archive).then(files => files.files).then(files => {
- const indexFile = files['index.json'];
- if (!indexFile) {
- return Promise.reject('no dictionary index found in archive');
- }
-
- return indexFile.async('string').then(indexJson => {
- const index = JSON.parse(indexJson);
- if (!index.title || !index.version || !index.revision) {
- return Promise.reject('unrecognized dictionary format');
- }
-
- return indexLoaded(
- index.title,
- index.version,
- index.revision,
- index.tagMeta || {},
- index.termBanks > 0,
- index.kanjiBanks > 0
- ).then(() => index);
- }).then(index => {
- const loaders = [];
- const banksTotal = index.termBanks + index.kanjiBanks;
- let banksLoaded = 0;
-
- for (let i = 1; i <= index.termBanks; ++i) {
- const bankFile = files[`term_bank_${i}.json`];
- if (!bankFile) {
- return Promise.reject('missing term bank file');
- }
-
- loaders.push(() => bankFile.async('string').then(bankJson => {
- const bank = JSON.parse(bankJson);
- return termsLoaded(index.title, bank, banksTotal, banksLoaded++);
- }));
- }
-
- for (let i = 1; i <= index.kanjiBanks; ++i) {
- const bankFile = files[`kanji_bank_${i}.json`];
- if (!bankFile) {
- return Promise.reject('missing kanji bank file');
- }
-
- loaders.push(() => bankFile.async('string').then(bankJson => {
- const bank = JSON.parse(bankJson);
- return kanjiLoaded(index.title, bank, banksTotal, banksLoaded++);
- }));
- }
-
- let chain = Promise.resolve();
- for (const loader of loaders) {
- chain = chain.then(loader);
- }
-
- return chain;
- });
- });
-}
-
-/*
* Helpers
*/