summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-08-19 17:30:38 -0700
committerAlex Yatskov <alex@foosoft.net>2017-08-19 17:30:38 -0700
commitd5b4b0499842023fab57a8231d7e0eb80737deab (patch)
tree54470d711f4fd6cc25a0befeb6ff36e8aa28bb8e /ext
parent6a2e272f116c539ddd0fbf474509537d6b4529af (diff)
parentbecf549dcec03b1a5aff8ff9033fc7d14b8a2541 (diff)
Merge branch 'master' into firefox-amo
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/api.js31
-rw-r--r--ext/bg/js/dictionary.js5
-rw-r--r--ext/bg/js/handlebars.js2
-rw-r--r--ext/bg/js/settings.js12
-rw-r--r--ext/manifest.json2
5 files changed, 26 insertions, 26 deletions
diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js
index 2afe82a0..96147d95 100644
--- a/ext/bg/js/api.js
+++ b/ext/bg/js/api.js
@@ -66,22 +66,27 @@ async function apiDefinitionAdd(definition, mode) {
}
async function apiDefinitionsAddable(definitions, modes) {
- const notes = [];
- for (const definition of definitions) {
- for (const mode of modes) {
- notes.push(dictNoteFormat(definition, mode, utilBackend().options));
- }
- }
-
- const results = await utilBackend().anki.canAddNotes(notes);
const states = [];
- for (let resultBase = 0; resultBase < results.length; resultBase += modes.length) {
- const state = {};
- for (let modeOffset = 0; modeOffset < modes.length; ++modeOffset) {
- state[modes[modeOffset]] = results[resultBase + modeOffset];
+
+ try {
+ const notes = [];
+ for (const definition of definitions) {
+ for (const mode of modes) {
+ notes.push(dictNoteFormat(definition, mode, utilBackend().options));
+ }
}
- states.push(state);
+ const results = await utilBackend().anki.canAddNotes(notes);
+ for (let resultBase = 0; resultBase < results.length; resultBase += modes.length) {
+ const state = {};
+ for (let modeOffset = 0; modeOffset < modes.length; ++modeOffset) {
+ state[modes[modeOffset]] = results[resultBase + modeOffset];
+ }
+
+ states.push(state);
+ }
+ } catch (e) {
+ // NOP
}
return states;
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index c8d431b9..2a80e2d0 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -223,10 +223,7 @@ function dictFieldFormat(field, definition, mode, options) {
modeKanji: mode === 'kanji'
};
- field = field.replace(
- `{${marker}}`,
- handlebarsRender('fields.html', data)
- );
+ field = field.replace(`{${marker}}`, handlebarsRender('fields.html', data));
}
return field;
diff --git a/ext/bg/js/handlebars.js b/ext/bg/js/handlebars.js
index debb0690..a13de153 100644
--- a/ext/bg/js/handlebars.js
+++ b/ext/bg/js/handlebars.js
@@ -51,5 +51,5 @@ function handlebarsRender(template, data) {
Handlebars.registerHelper('multiLine', handlebarsMultiLine);
}
- return Handlebars.templates[template](data);
+ return Handlebars.templates[template](data).trim();
}
diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js
index 7bdd9f84..b8cb4afe 100644
--- a/ext/bg/js/settings.js
+++ b/ext/bg/js/settings.js
@@ -331,11 +331,6 @@ function ankiFieldsToDict(selection) {
async function ankiDeckAndModelPopulate(options) {
const ankiFormat = $('#anki-format').hide();
- const ankiTermsModel = $('#anki-terms-model').val(options.anki.terms.model);
- const ankiKanjiModel = $('#anki-kanji-model').val(options.anki.kanji.model);
-
- $('#anki-terms-deck').val(options.anki.terms.deck);
- $('#anki-kanji-deck').val(options.anki.kanji.deck);
const deckNames = await utilAnkiGetDeckNames();
const ankiDeck = $('.anki-deck');
@@ -347,8 +342,11 @@ async function ankiDeckAndModelPopulate(options) {
ankiModel.find('option').remove();
modelNames.sort().forEach(name => ankiModel.append($('<option/>', {value: name, text: name})));
- await ankiFieldsPopulate(ankiTermsModel, options);
- await ankiFieldsPopulate(ankiKanjiModel, options);
+ $('#anki-terms-deck').val(options.anki.terms.deck);
+ await ankiFieldsPopulate($('#anki-terms-model').val(options.anki.terms.model), options);
+
+ $('#anki-kanji-deck').val(options.anki.kanji.deck);
+ await ankiFieldsPopulate($('#anki-kanji-model').val(options.anki.kanji.model), options);
ankiFormat.show();
}
diff --git a/ext/manifest.json b/ext/manifest.json
index 94182896..744ece39 100644
--- a/ext/manifest.json
+++ b/ext/manifest.json
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Yomichan",
- "version": "1.3.0",
+ "version": "1.3.2",
"description": "Japanese dictionary with Anki integration",
"icons": {"16": "mixed/img/icon16.png", "48": "mixed/img/icon48.png", "128": "mixed/img/icon128.png"},