From 2e3aec9ba11b15d7ac2b5d99af2dacac88e9c276 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Wed, 8 Feb 2017 20:13:45 -0800 Subject: fix "url" not being set on kanji cards, add more fields --- ext/bg/js/options-form.js | 2 +- ext/fg/js/driver.js | 6 +++++- ext/fg/js/frame.js | 10 +++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js index 4470d105..91c6f140 100644 --- a/ext/bg/js/options-form.js +++ b/ext/bg/js/options-form.js @@ -351,7 +351,7 @@ function populateAnkiFields(element, options) { const markers = { 'terms': ['audio', 'dictionary', 'expression', 'furigana', 'glossary', 'reading', 'sentence', 'tags', 'url'], - 'kanji': ['character', 'dictionary', 'glossary', 'kunyomi', 'onyomi', 'url'] + 'kanji': ['character', 'dictionary', 'glossary', 'kunyomi', 'onyomi', 'sentence', 'tags', 'url'] }[tabId] || {}; return anki().getModelFieldNames(modelName).then(names => { diff --git a/ext/fg/js/driver.js b/ext/fg/js/driver.js index 7facda0a..cb7f2ea6 100644 --- a/ext/fg/js/driver.js +++ b/ext/fg/js/driver.js @@ -167,7 +167,11 @@ class Driver { if (definitions.length === 0) { return false; } else { - definitions.forEach(definition => definition.url = window.location.href); + const sentence = extractSentence(textSource, this.options.anki.sentenceExt); + definitions.forEach(definition => { + definition.url = window.location.href; + definition.sentence = sentence; + }); this.popup.showNextTo(textSource.getRect()); this.popup.showKanjiDefs(definitions, this.options); diff --git a/ext/fg/js/frame.js b/ext/fg/js/frame.js index dba59000..df8ca894 100644 --- a/ext/fg/js/frame.js +++ b/ext/fg/js/frame.js @@ -49,7 +49,15 @@ class Frame { $('.kanji-link').click(e => { e.preventDefault(); - findKanji($(e.target).text()).then(kdefs => this.api_showKanjiDefs({options, definitions: kdefs})); + const character = $(e.target).text(); + findKanji(character).then(kdefs => { + kdefs.forEach(kdef => { + kdef.url = definitions[0].url; + kdef.sentence = definitions[0].sentence; + }); + + this.api_showKanjiDefs({options, definitions: kdefs}); + }); }); $('.action-play-audio').click(e => { -- cgit v1.2.3