From d960ba6dd65434af7f61a7da2270299d1a98cd27 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Fri, 18 Aug 2017 09:42:34 -0700 Subject: [PATCH 1/7] fixing bugs, new version --- ext/bg/js/dictionary.js | 2 +- ext/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index c8d431b9..fc479e85 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -225,7 +225,7 @@ function dictFieldFormat(field, definition, mode, options) { field = field.replace( `{${marker}}`, - handlebarsRender('fields.html', data) + handlebarsRender('fields.html', data).trim() ); } diff --git a/ext/manifest.json b/ext/manifest.json index f0c67020..736dee2d 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.1", "description": "Japanese dictionary with Anki integration", "icons": {"16": "mixed/img/icon16.png", "48": "mixed/img/icon48.png", "128": "mixed/img/icon128.png"}, From 922d2cd468ec1d05fc4d68f60419a6af11aa5c94 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Fri, 18 Aug 2017 21:05:17 -0700 Subject: [PATCH 2/7] version bump --- ext/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/manifest.json b/ext/manifest.json index 736dee2d..7b0a61a5 100644 --- a/ext/manifest.json +++ b/ext/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Yomichan", - "version": "1.3.1", + "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"}, From 30fe3d250646e0993cc49a7ef6b783eee206d043 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Fri, 18 Aug 2017 21:14:09 -0700 Subject: [PATCH 3/7] fix anki network error dialog on search page, cleanup template workaround --- ext/bg/js/api.js | 33 ++++++++++++++++++++------------- ext/bg/js/dictionary.js | 5 +---- ext/bg/js/handlebars.js | 2 +- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js index 2afe82a0..4676e2dc 100644 --- a/ext/bg/js/api.js +++ b/ext/bg/js/api.js @@ -66,22 +66,29 @@ 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); + } + + return states; + } catch (e) { + // NOP } return states; diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index fc479e85..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).trim() - ); + 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(); } From 112bf36f88beff12e8196542444c531f1493c6ee Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Fri, 18 Aug 2017 21:33:30 -0700 Subject: [PATCH 4/7] cleanup --- ext/bg/js/api.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js index 4676e2dc..96147d95 100644 --- a/ext/bg/js/api.js +++ b/ext/bg/js/api.js @@ -85,8 +85,6 @@ async function apiDefinitionsAddable(definitions, modes) { states.push(state); } - - return states; } catch (e) { // NOP } From 7219bc99f5f018bb86283333660241d1774845fa Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 19 Aug 2017 11:23:19 -0700 Subject: [PATCH 5/7] fixing deck and model not being set correctly --- ext/bg/js/settings.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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($('