aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/frame.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-02-10 20:45:01 -0800
committerAlex Yatskov <alex@foosoft.net>2017-02-10 20:45:01 -0800
commit78d5b511278cd9b8f9319220bec55b8628f6cb36 (patch)
treed5f181b03c28adc06f705c1fa286bfdeaeb55cdf /ext/fg/js/frame.js
parentcaa09c63a18a0d5f30fda365c18c0d58235ec7e9 (diff)
fix url and sentence tags on kanji cards
Diffstat (limited to 'ext/fg/js/frame.js')
-rw-r--r--ext/fg/js/frame.js31
1 files changed, 17 insertions, 14 deletions
diff --git a/ext/fg/js/frame.js b/ext/fg/js/frame.js
index df8ca894..83d6d7ef 100644
--- a/ext/fg/js/frame.js
+++ b/ext/fg/js/frame.js
@@ -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));