fix url and sentence tags on kanji cards
This commit is contained in:
parent
caa09c63a1
commit
78d5b51127
@ -143,13 +143,11 @@ class Driver {
|
||||
textSource.setEndOffset(length);
|
||||
|
||||
const sentence = extractSentence(textSource, this.options.anki.sentenceExt);
|
||||
definitions.forEach(definition => {
|
||||
definition.url = window.location.href;
|
||||
definition.sentence = sentence;
|
||||
});
|
||||
const url = window.location.href;
|
||||
|
||||
this.popup.showNextTo(textSource.getRect());
|
||||
this.popup.showTermDefs(definitions, this.options);
|
||||
this.popup.showTermDefs(definitions, this.options, {sentence, url});
|
||||
|
||||
this.lastTextSource = textSource;
|
||||
if (this.options.scanning.selectText) {
|
||||
textSource.select();
|
||||
@ -168,13 +166,11 @@ class Driver {
|
||||
return false;
|
||||
} else {
|
||||
const sentence = extractSentence(textSource, this.options.anki.sentenceExt);
|
||||
definitions.forEach(definition => {
|
||||
definition.url = window.location.href;
|
||||
definition.sentence = sentence;
|
||||
});
|
||||
const url = window.location.href;
|
||||
|
||||
this.popup.showNextTo(textSource.getRect());
|
||||
this.popup.showKanjiDefs(definitions, this.options);
|
||||
this.popup.showKanjiDefs(definitions, this.options, {sentence, url});
|
||||
|
||||
this.lastTextSource = textSource;
|
||||
if (this.options.scanning.selectText) {
|
||||
textSource.select();
|
||||
|
@ -30,34 +30,32 @@ class Frame {
|
||||
});
|
||||
}
|
||||
|
||||
api_showTermDefs({definitions, options}) {
|
||||
api_showTermDefs({definitions, options, context}) {
|
||||
const sequence = ++this.sequence;
|
||||
const context = {
|
||||
const params = {
|
||||
definitions,
|
||||
grouped: options.general.groupResults,
|
||||
addable: options.ankiMethod !== 'disabled',
|
||||
playback: options.general.audioPlayback
|
||||
};
|
||||
|
||||
definitions.forEach(definition => {
|
||||
definition.sentence = context.sentence;
|
||||
definition.url = context.url;
|
||||
});
|
||||
|
||||
this.definitions = definitions;
|
||||
this.showSpinner(false);
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
renderText(context, 'terms.html').then(content => {
|
||||
renderText(params, 'terms.html').then(content => {
|
||||
$('#content').html(content);
|
||||
$('.action-add-note').click(this.onAddNote.bind(this));
|
||||
|
||||
$('.kanji-link').click(e => {
|
||||
e.preventDefault();
|
||||
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});
|
||||
});
|
||||
findKanji(character).then(definitions => this.api_showKanjiDefs({definitions, options, context}));
|
||||
});
|
||||
|
||||
$('.action-play-audio').click(e => {
|
||||
@ -72,18 +70,23 @@ class Frame {
|
||||
});
|
||||
}
|
||||
|
||||
api_showKanjiDefs({definitions, options}) {
|
||||
api_showKanjiDefs({definitions, options, context}) {
|
||||
const sequence = ++this.sequence;
|
||||
const context = {
|
||||
const params = {
|
||||
definitions,
|
||||
addable: options.ankiMethod !== 'disabled'
|
||||
};
|
||||
|
||||
definitions.forEach(definition => {
|
||||
definition.sentence = context.sentence;
|
||||
definition.url = context.url;
|
||||
});
|
||||
|
||||
this.definitions = definitions;
|
||||
this.showSpinner(false);
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
renderText(context, 'kanji.html').then(content => {
|
||||
renderText(params, 'kanji.html').then(content => {
|
||||
$('#content').html(content);
|
||||
$('.action-add-note').click(this.onAddNote.bind(this));
|
||||
|
||||
|
@ -68,12 +68,12 @@ class Popup {
|
||||
return this.container.style.visibility !== 'hidden';
|
||||
}
|
||||
|
||||
showTermDefs(definitions, options) {
|
||||
this.invokeApi('showTermDefs', {definitions, options});
|
||||
showTermDefs(definitions, options, context) {
|
||||
this.invokeApi('showTermDefs', {definitions, options, context});
|
||||
}
|
||||
|
||||
showKanjiDefs(definitions, options) {
|
||||
this.invokeApi('showKanjiDefs', {definitions, options});
|
||||
showKanjiDefs(definitions, options, context) {
|
||||
this.invokeApi('showKanjiDefs', {definitions, options, context});
|
||||
}
|
||||
|
||||
showOrphaned() {
|
||||
|
Loading…
Reference in New Issue
Block a user