From fd2820bc1af1f2a4dac477f1d2963a3b913fdb32 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 5 Nov 2016 16:44:29 -0700 Subject: WIP --- ext/bg/js/util.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'ext/bg/js/util.js') diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index 4e0cc671..888bcb33 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -116,3 +116,27 @@ function applyTagMeta(tag, meta) { function splitField(field) { return field.length === 0 ? [] : field.split(' '); } + +function importJsonDb(indexUrl, entitiesLoaded, entriesLoaded) { + const indexDir = indexUrl.slice(0, indexUrl.lastIndexOf('/')); + return loadJson(indexUrl).then(index => { + if (entitiesLoaded !== null) { + return entitiesLoaded(index.entities, index.banks).then(() => index); + } + + return index; + }).then(index => { + const loaders = []; + for (let i = 1; i <= index.banks; ++i) { + const bankUrl = `${indexDir}/bank_${i}.json`; + loaders.push(() => loadJson(bankUrl).then(entries => entriesLoaded(entries, index.banks, i))); + } + + let chain = Promise.resolve(); + for (const loader of loaders) { + chain = chain.then(loader); + } + + return chain; + }); +} -- cgit v1.2.3 From e2f1560afa25274d3b0efd3ce8fc8a17740ab7cc Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 5 Nov 2016 17:30:00 -0700 Subject: WIP --- ext/bg/js/dictionary.js | 41 +++++++++++++++++++++++++++++------------ ext/bg/js/util.js | 8 ++++---- 2 files changed, 33 insertions(+), 16 deletions(-) (limited to 'ext/bg/js/util.js') diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index 2c9636ab..a2a4047a 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 = 3; + this.dbVer = 4; this.entities = null; } @@ -31,10 +31,10 @@ class Dictionary { this.db = new Dexie('dict'); this.db.version(1).stores({ - terms: '++id,expression,reading', - entities: '++,name', - kanji: '++,character', - meta: 'name,value', + terms: '++id, dictionary, expression, reading', + kanji: '++, dictionary, character', + entities: '++, dictionary, name', + meta: 'name, value', }); } @@ -135,21 +135,31 @@ class Dictionary { return Promise.reject('database not initialized'); } - const entitiesLoaded = entities => { + const indexLoaded = (dictionary, entities) => { this.entities = entities || {}; const rows = []; for (const name in entities || {}) { - rows.push({name, value: entities[name]}); + rows.push({ + dictionary, + name, + value: entities[name] + }); } return this.db.entities.bulkAdd(rows); }; - const entriesLoaded = (entries, total, current) => { + const entriesLoaded = (dictionary, entries, total, current) => { const rows = []; for (const [expression, reading, tags, ...glossary] of entries) { - rows.push({expression, reading, tags, glossary}); + rows.push({ + dictionary, + expression, + reading, + tags, + glossary + }); } return this.db.terms.bulkAdd(rows).then(() => { @@ -159,7 +169,7 @@ class Dictionary { }); }; - return importJsonDb(indexUrl, entitiesLoaded, entriesLoaded); + return importJsonDb(indexUrl, indexLoaded, entriesLoaded); } importKanjiDict(indexUrl, callback) { @@ -167,10 +177,17 @@ class Dictionary { return Promise.reject('database not initialized'); } - const entriesLoaded = (entries, total, current) => { + const entriesLoaded = (dictionary, entries, total, current) => { const rows = []; for (const [character, onyomi, kunyomi, tags, ...meanings] of entries) { - rows.push({character, onyomi, kunyomi, tags, meanings}); + rows.push({ + dictionary, + character, + onyomi, + kunyomi, + tags, + meanings + }); } return this.db.kanji.bulkAdd(rows).then(() => { diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index 888bcb33..9b17f43c 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -117,11 +117,11 @@ function splitField(field) { return field.length === 0 ? [] : field.split(' '); } -function importJsonDb(indexUrl, entitiesLoaded, entriesLoaded) { +function importJsonDb(indexUrl, indexLoaded, entriesLoaded) { const indexDir = indexUrl.slice(0, indexUrl.lastIndexOf('/')); return loadJson(indexUrl).then(index => { - if (entitiesLoaded !== null) { - return entitiesLoaded(index.entities, index.banks).then(() => index); + if (indexLoaded !== null) { + return indexLoaded(index.title, index.entities, index.banks).then(() => index); } return index; @@ -129,7 +129,7 @@ function importJsonDb(indexUrl, entitiesLoaded, entriesLoaded) { const loaders = []; for (let i = 1; i <= index.banks; ++i) { const bankUrl = `${indexDir}/bank_${i}.json`; - loaders.push(() => loadJson(bankUrl).then(entries => entriesLoaded(entries, index.banks, i))); + loaders.push(() => loadJson(bankUrl).then(entries => entriesLoaded(index.title, entries, index.banks, i))); } let chain = Promise.resolve(); -- cgit v1.2.3 From d3a01738740c9a38011e5b98b3f37709bea515e1 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 5 Nov 2016 17:51:01 -0700 Subject: Dictionary naming --- ext/bg/js/dictionary.js | 38 +++++++++++++++++++++++--------------- ext/bg/js/util.js | 4 ++-- 2 files changed, 25 insertions(+), 17 deletions(-) (limited to 'ext/bg/js/util.js') 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({ diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index 9b17f43c..ac365135 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -121,7 +121,7 @@ function importJsonDb(indexUrl, indexLoaded, entriesLoaded) { const indexDir = indexUrl.slice(0, indexUrl.lastIndexOf('/')); return loadJson(indexUrl).then(index => { if (indexLoaded !== null) { - return indexLoaded(index.title, index.entities, index.banks).then(() => index); + return indexLoaded(index.title, index.version, index.entities, index.banks).then(() => index); } return index; @@ -129,7 +129,7 @@ function importJsonDb(indexUrl, indexLoaded, entriesLoaded) { const loaders = []; for (let i = 1; i <= index.banks; ++i) { const bankUrl = `${indexDir}/bank_${i}.json`; - loaders.push(() => loadJson(bankUrl).then(entries => entriesLoaded(index.title, entries, index.banks, i))); + loaders.push(() => loadJson(bankUrl).then(entries => entriesLoaded(index.title, index.version, entries, index.banks, i))); } let chain = Promise.resolve(); -- cgit v1.2.3 From 3f606a0ab00a084e7f22b232cdd5a7006ab7d636 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 6 Nov 2016 11:01:35 -0800 Subject: Combined import --- ext/bg/js/dictionary.js | 28 ++++++++------------------- ext/bg/js/options-form.js | 2 +- ext/bg/js/translator.js | 8 ++++---- ext/bg/js/util.js | 48 +++++++++++++++++++++++++++++++++-------------- 4 files changed, 47 insertions(+), 39 deletions(-) (limited to 'ext/bg/js/util.js') 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); } } diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js index 5327a04a..060ee269 100644 --- a/ext/bg/js/options-form.js +++ b/ext/bg/js/options-form.js @@ -158,7 +158,7 @@ function populateDictionaries() { // const dictGroups = $('.dictionaries'); // dictGroups.empty(); - // yomichan().translator.dictionary.getDictionaries().then(rows => { + // yomichan().translator.dictionary.getNames().then(rows => { // for (const row of rows) { // const dictPanel = $('
', {class: 'dictionary panel panel-default'}); // const dictRow = $('
', {class: 'panel-body row'}).appendTo(dictPanel); diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index 44f37e31..8e0c522f 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -46,7 +46,7 @@ class Translator { } const banks = {}; - const bankCallback = (loaded, total, indexUrl) => { + const bankCallback = (total, loaded, indexUrl) => { banks[indexUrl] = {loaded, total}; let percent = 0.0; @@ -62,9 +62,9 @@ class Translator { }; return Promise.all([ - this.dictionary.importTermDict('bg/data/edict/index.json', bankCallback), - this.dictionary.importTermDict('bg/data/enamdict/index.json', bankCallback), - this.dictionary.importKanjiDict('bg/data/kanjidic/index.json', bankCallback), + this.dictionary.importDb('bg/data/edict/index.json', bankCallback), + this.dictionary.importDb('bg/data/enamdict/index.json', bankCallback), + this.dictionary.importDb('bg/data/kanjidic/index.json', bankCallback), ]).then(() => { return this.dictionary.sealDb(); }).then(() => { diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index ac365135..eaa7dd01 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -43,15 +43,6 @@ function promiseCallback(promise, callback) { }); } -function loadJson(url) { - return new Promise((resolve, reject) => { - const xhr = new XMLHttpRequest(); - xhr.addEventListener('load', () => resolve(JSON.parse(xhr.responseText))); - xhr.open('GET', chrome.extension.getURL(url)); - xhr.send(); - }); -} - function sortTags(tags) { return tags.sort((v1, v2) => { const order1 = v1.order; @@ -117,19 +108,48 @@ function splitField(field) { return field.length === 0 ? [] : field.split(' '); } -function importJsonDb(indexUrl, indexLoaded, entriesLoaded) { +function loadJson(url) { + return new Promise((resolve, reject) => { + const xhr = new XMLHttpRequest(); + xhr.addEventListener('load', () => resolve(JSON.parse(xhr.responseText))); + xhr.open('GET', chrome.extension.getURL(url)); + xhr.send(); + }); +} + +function importJsonDb(indexUrl, indexLoaded, termsLoaded, kanjiLoaded) { const indexDir = indexUrl.slice(0, indexUrl.lastIndexOf('/')); return loadJson(indexUrl).then(index => { if (indexLoaded !== null) { - return indexLoaded(index.title, index.version, index.entities, index.banks).then(() => index); + return indexLoaded(index.title, index.version).then(() => index); } return index; }).then(index => { const loaders = []; - for (let i = 1; i <= index.banks; ++i) { - const bankUrl = `${indexDir}/bank_${i}.json`; - loaders.push(() => loadJson(bankUrl).then(entries => entriesLoaded(index.title, index.version, entries, index.banks, i))); + const banksTotal = index.termBanks + index.kanjiBanks; + let banksLoaded = 0; + + for (let i = 1; i <= index.termBanks; ++i) { + const bankUrl = `${indexDir}/term_bank_${i}.json`; + loaders.push(() => loadJson(bankUrl).then(entries => termsLoaded( + index.title, + index.version, + entries, + banksTotal, + banksLoaded++ + ))); + } + + for (let i = 1; i <= index.kanjiBanks; ++i) { + const bankUrl = `${indexDir}/kanji_bank_${i}.json`; + loaders.push(() => loadJson(bankUrl).then(entries => kanjiLoaded( + index.title, + index.version, + entries, + banksTotal, + banksLoaded++ + ))); } let chain = Promise.resolve(); -- cgit v1.2.3 From fd6622400f64b2d568d38bde72f9fd75f8d06beb Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 6 Nov 2016 17:10:31 -0800 Subject: Templates --- ext/bg/js/dictionary.js | 10 +++++----- ext/bg/js/options-form.js | 36 +++++++++++++++++------------------- ext/bg/js/templates.js | 18 ++++++++++++++++++ ext/bg/js/util.js | 10 +++++++--- ext/bg/options.html | 14 ++++++++------ tmpl/dictionary.html | 21 +++++++++++++++++++++ 6 files changed, 76 insertions(+), 33 deletions(-) create mode 100644 tmpl/dictionary.html (limited to 'ext/bg/js/util.js') diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index 5859350b..008bc483 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -131,7 +131,7 @@ class Dictionary { }); } - getNames() { + getInfo() { if (this.db === null) { return Promise.reject('database not initialized'); } @@ -144,8 +144,8 @@ class Dictionary { return Promise.reject('database not initialized'); } - const indexLoaded = (dictionary, version, entities) => { - return this.db.dictionaries.add({dictionary, version}).then(() => { + const indexLoaded = (dictionary, version, entities, hasTerms, hasKanji) => { + return this.db.dictionaries.add({dictionary, version, hasTerms, hasKanji}).then(() => { this.entities = entities || {}; const rows = []; @@ -161,7 +161,7 @@ class Dictionary { }); }; - const termsLoaded = (dictionary, version, entries, total, current) => { + const termsLoaded = (dictionary, entries, total, current) => { const rows = []; for (const [expression, reading, tags, ...glossary] of entries) { rows.push({ @@ -180,7 +180,7 @@ class Dictionary { }); }; - const kanjiLoaded = (dictionary, version, entries, total, current) => { + const kanjiLoaded = (dictionary, entries, total, current) => { const rows = []; for (const [character, onyomi, kunyomi, tags, ...meanings] of entries) { rows.push({ diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js index 060ee269..ec603eed 100644 --- a/ext/bg/js/options-form.js +++ b/ext/bg/js/options-form.js @@ -155,25 +155,21 @@ function populateAnkiDeckAndModel(opts) { } function populateDictionaries() { - // const dictGroups = $('.dictionaries'); - // dictGroups.empty(); - - // yomichan().translator.dictionary.getNames().then(rows => { - // for (const row of rows) { - // const dictPanel = $('
', {class: 'dictionary panel panel-default'}); - // const dictRow = $('
', {class: 'panel-body row'}).appendTo(dictPanel); - - // const title = $('
', {class: 'col-xs-8'}); - // $('

').append().html(` ${row.dictionary} v.${row.version}`).appendTo(title); - // title.appendTo(dictRow); - - // const controls = $('
', {class: 'col-xs-4 text-right'}); - // $('\n
\n

\n\n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.hasTerms : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.hasKanji : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
\n"; +},"useData":true}); templates['footer.html'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { var helper; diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index eaa7dd01..e99cdeab 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -121,7 +121,13 @@ function importJsonDb(indexUrl, indexLoaded, termsLoaded, kanjiLoaded) { const indexDir = indexUrl.slice(0, indexUrl.lastIndexOf('/')); return loadJson(indexUrl).then(index => { if (indexLoaded !== null) { - return indexLoaded(index.title, index.version).then(() => index); + return indexLoaded( + index.title, + index.version, + index.entities, + index.termBanks > 0, + index.kanjiBanks > 0 + ).then(() => index); } return index; @@ -134,7 +140,6 @@ function importJsonDb(indexUrl, indexLoaded, termsLoaded, kanjiLoaded) { const bankUrl = `${indexDir}/term_bank_${i}.json`; loaders.push(() => loadJson(bankUrl).then(entries => termsLoaded( index.title, - index.version, entries, banksTotal, banksLoaded++ @@ -145,7 +150,6 @@ function importJsonDb(indexUrl, indexLoaded, termsLoaded, kanjiLoaded) { const bankUrl = `${indexDir}/kanji_bank_${i}.json`; loaders.push(() => loadJson(bankUrl).then(entries => kanjiLoaded( index.title, - index.version, entries, banksTotal, banksLoaded++ diff --git a/ext/bg/options.html b/ext/bg/options.html index 1136eefc..acd786cf 100644 --- a/ext/bg/options.html +++ b/ext/bg/options.html @@ -124,18 +124,18 @@
- -

Yomichan features automatic flashcard creation for Anki, a free application designed to help you retain knowledge. While the AnkiConnect plugin offers the best experience, it is also possible to create flashcards through AnkiWeb, provided you already have an account.

+ +
@@ -217,6 +217,8 @@ + + diff --git a/tmpl/dictionary.html b/tmpl/dictionary.html new file mode 100644 index 00000000..21847722 --- /dev/null +++ b/tmpl/dictionary.html @@ -0,0 +1,21 @@ +
+
+
+

{{name}} v.{{version}}

+
+
+ +
+
+ + {{#if hasTerms}} +
+ +
+ {{/if}} + {{#if hasKanji}} +
+ +
+ {{/if}} +
-- cgit v1.2.3 From 8f995194bbf23a074a901c8fdaf4ddad22370dd3 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 7 Nov 2016 09:16:38 -0800 Subject: WIP --- ext/bg/js/options-form.js | 47 +++++++++++++++++++++++++++++++++++++++++++---- ext/bg/js/templates.js | 2 +- ext/bg/js/util.js | 1 + ext/bg/options.html | 6 +++--- tmpl/dictionary.html | 2 +- 5 files changed, 49 insertions(+), 9 deletions(-) (limited to 'ext/bg/js/util.js') diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js index 14143d81..ce829698 100644 --- a/ext/bg/js/options-form.js +++ b/ext/bg/js/options-form.js @@ -166,6 +166,9 @@ function populateDictionaries(opts) { const container = $('.dicts'); container.empty(); + const dictError = $('#dict-error'); + dictError.hide(); + yomichan().translator.database.getDictionaries().then(rows => { rows.forEach(row => { const dictOpts = opts.dictionaries[row.title] || {enableTerms: true, enableKanji: false}; @@ -182,13 +185,47 @@ function populateDictionaries(opts) { }); $('.dict-delete').click(e => { - const dict = $(e.target).closest('.dict'); + const button = $(e.target); + const dict = button.closest('.dict'); const title = dict.data('title'); - yomichan().translator.database.deleteDictionary(title); - dict.slideUp(); + + button.prop('disabled', true); + yomichan().translator.database.deleteDictionary(title).then(() => { + dict.slideUp(); + }).catch(error => { + dictError.show().find('span').text(error); + }).then(() => { + button.prop('disabled', false); + }); }); container.find('.dict input').change(onOptionsChanged); + }).catch(error => { + dictError.show().find('span').text(error); + }); +} + +function onImportDictionary() { + const dictInputs = $('#dict-import').find('input'); + dictInputs.prop('disabled', true); + + const dictError = $('#dict-error'); + dictError.hide(); + + const progressbar = $('#dict-import-progress'); + const progressValue = progressbar.find('div'); + progressbar.show(); + + const callback = (total, current) => { + $('.progress-bar').css('width', `${current / total * 100.0}%`); + }; + + const dictUrl = $('#dict-import-url').val(); + yomichan().translator.database.importDictionary(dictUrl, callback).catch(error => { + dictError.show().find('span').text(error); + }).then(() => { + dictInputs.prop('disabled', false); + progressbar.hide(); }); } @@ -303,7 +340,7 @@ $(document).ready(() => { if (url.includes('/')) { control.val(url); } else { - control.val(chrome.extension.getURL(`bg/data/${url}`)); + control.val(chrome.extension.getURL(`bg/data/${url}/index.json`)); } control.trigger('input'); }); @@ -314,6 +351,8 @@ $(document).ready(() => { $('#dict-import-start').prop('disabled', disable); }); + $('#dict-import-start').click(onImportDictionary); + populateDictionaries(opts); populateAnkiDeckAndModel(opts); updateVisibility(opts); diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js index d42d972d..ce44de8d 100644 --- a/ext/bg/js/templates.js +++ b/ext/bg/js/templates.js @@ -13,7 +13,7 @@ templates['dictionary.html'] = template({"1":function(container,depth0,helpers,p + alias4(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper))) + " v." + alias4(((helper = (helper = helpers.version || (depth0 != null ? depth0.version : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"version","hash":{},"data":data}) : helper))) - + "\n
\n
\n \n
\n
\n\n
\n
\n
\n \n
\n
\n\n
\n