summaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/database.js4
-rw-r--r--ext/bg/js/options-form.js79
2 files changed, 46 insertions, 37 deletions
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js
index 6a171dd4..23041e40 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/database.js
@@ -159,7 +159,7 @@ class Database {
let termDeleter = Promise.resolve();
if (info.hasTerms) {
const termDeleterFunc = () => {
- return this.db.terms.where('dictionary').equals(title).limit(1000).delete().then(count => {
+ return this.db.terms.where('dictionary').equals(title).limit(500).delete().then(count => {
if (count === 0) {
return Promise.resolve();
}
@@ -179,7 +179,7 @@ class Database {
let kanjiDeleter = Promise.resolve();
if (info.hasKanji) {
const kanjiDeleterFunc = () => {
- return this.db.kanji.where('dictionary').equals(title).limit(1000).delete().then(count => {
+ return this.db.kanji.where('dictionary').equals(title).limit(500).delete().then(count => {
if (count === 0) {
return Promise.resolve();
}
diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js
index 736ec023..2cabe162 100644
--- a/ext/bg/js/options-form.js
+++ b/ext/bg/js/options-form.js
@@ -115,40 +115,6 @@ function updateVisibility(opts) {
}
}
-function populateDictionaries(opts) {
- const dictGroups = $('#dict-groups');
- dictGroups.empty();
-
- const dictError = $('#dict-error');
- dictError.hide();
-
- const dictSpinner = $('#dict-spinner');
- dictSpinner.show();
-
- return database().getDictionaries().then(rows => {
- rows.forEach(row => {
- const dictOpts = opts.dictionaries[row.title] || {enableTerms: false, enableKanji: false};
- const html = Handlebars.templates['dictionary.html']({
- title: row.title,
- version: row.version,
- hasTerms: row.hasTerms,
- hasKanji: row.hasKanji,
- enableTerms: dictOpts.enableTerms,
- enableKanji: dictOpts.enableKanji
- });
-
- dictGroups.append($(html));
- });
-
- $('.dict-enable-terms, .dict-enable-kanji').change(onOptionsChanged);
- $('.dict-delete').click(onDictionaryDelete);
- }).catch(error => {
- dictError.show().find('span').text(error);
- }).then(() => {
- dictSpinner.hide();
- });
-}
-
function onDictionaryDelete() {
const dictGroup = $(this).closest('.dict-group');
@@ -199,7 +165,7 @@ function onDictionaryImport() {
const dictUrl = $('#dict-url');
loadOptions().then(opts => {
database().importDictionary(dictUrl.val(), callback).then(summary => {
- opts.dictionaries[summary.title] = {hasTerms: summary.hasTerms, hasKanji: summary.hasKanji};
+ opts.dictionaries[summary.title] = {enableTerms: summary.hasTerms, enableKanji: summary.hasKanji};
return saveOptions(opts);
}).then(() => {
return populateDictionaries(opts);
@@ -302,6 +268,49 @@ function populateAnkiFields(element, opts) {
});
}
+function populateDictionaries(opts) {
+ const dictGroups = $('#dict-groups');
+ dictGroups.empty();
+
+ const dictError = $('#dict-error');
+ dictError.hide();
+
+ const dictWarning = $('#dict-warning');
+ dictWarning.hide();
+
+ const dictSpinner = $('#dict-spinner');
+ dictSpinner.show();
+
+ let dictCount = 0;
+ return database().getDictionaries().then(rows => {
+ rows.forEach(row => {
+ const dictOpts = opts.dictionaries[row.title] || {enableTerms: false, enableKanji: false};
+ const html = Handlebars.templates['dictionary.html']({
+ title: row.title,
+ version: row.version,
+ hasTerms: row.hasTerms,
+ hasKanji: row.hasKanji,
+ enableTerms: dictOpts.enableTerms,
+ enableKanji: dictOpts.enableKanji
+ });
+
+ dictGroups.append($(html));
+ ++dictCount;
+ });
+
+ $('.dict-enable-terms, .dict-enable-kanji').change(onOptionsChanged);
+ $('.dict-delete').click(onDictionaryDelete);
+ }).catch(error => {
+ dictError.show().find('span').text(error);
+ }).then(() => {
+ if (dictCount === 0) {
+ dictWarning.show();
+ }
+
+ dictSpinner.hide();
+ });
+}
+
function onOptionsChanged(e) {
if (!e.originalEvent && !e.isTrigger) {
return;