fix "url" not being set on kanji cards, add more fields

This commit is contained in:
Alex Yatskov 2017-02-08 20:13:45 -08:00
parent f3fe0994f5
commit 2e3aec9ba1
3 changed files with 15 additions and 3 deletions

View File

@ -351,7 +351,7 @@ function populateAnkiFields(element, options) {
const markers = { const markers = {
'terms': ['audio', 'dictionary', 'expression', 'furigana', 'glossary', 'reading', 'sentence', 'tags', 'url'], '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] || {}; }[tabId] || {};
return anki().getModelFieldNames(modelName).then(names => { return anki().getModelFieldNames(modelName).then(names => {

View File

@ -167,7 +167,11 @@ class Driver {
if (definitions.length === 0) { if (definitions.length === 0) {
return false; return false;
} else { } 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.showNextTo(textSource.getRect());
this.popup.showKanjiDefs(definitions, this.options); this.popup.showKanjiDefs(definitions, this.options);

View File

@ -49,7 +49,15 @@ class Frame {
$('.kanji-link').click(e => { $('.kanji-link').click(e => {
e.preventDefault(); 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 => { $('.action-play-audio').click(e => {