summaryrefslogtreecommitdiff
path: root/ext/mixed/js/display.js
diff options
context:
space:
mode:
authorAlex Yatskov <FooSoft@users.noreply.github.com>2017-12-16 11:20:14 -0800
committerGitHub <noreply@github.com>2017-12-16 11:20:14 -0800
commit2470b6209a27ceea814a13d920a20683bacf09a6 (patch)
tree7c0d664473c8472661b9c41c63eb7e5fd01d9706 /ext/mixed/js/display.js
parenta17e84de83e3f8750d41acf942c4fe476230d83a (diff)
parent15b93060c76ee4d59eb8ef90f6e1f8dea4c34ac9 (diff)
Merge pull request #103 from guidocella/play-audio-automatically
Add option to play audio automatically
Diffstat (limited to 'ext/mixed/js/display.js')
-rw-r--r--ext/mixed/js/display.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index 5d3c4f2e..43eb93c1 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -185,8 +185,7 @@ class Display {
80: /* p */ () => {
if (e.altKey) {
if ($('.entry').eq(this.index).data('type') === 'term') {
- const expressionIndex = this.options.general.resultOutputMode === 'merge' ? 0 : -1;
- this.audioPlay(this.definitions[this.index], expressionIndex);
+ this.audioPlay(this.definitions[this.index], this.firstExpressionIndex);
}
return true;
@@ -258,6 +257,10 @@ class Display {
this.container.html(content);
this.entryScrollIntoView(context && context.index || 0);
+ if (this.options.general.autoPlayAudio && this.options.general.audioSource !== 'disabled') {
+ this.autoPlayAudio();
+ }
+
$('.action-add-note').click(this.onNoteAdd.bind(this));
$('.action-view-note').click(this.onNoteView.bind(this));
$('.action-play-audio').click(this.onAudioPlay.bind(this));
@@ -309,6 +312,10 @@ class Display {
}
}
+ autoPlayAudio() {
+ this.audioPlay(this.definitions[0], this.firstExpressionIndex);
+ }
+
async adderButtonUpdate(modes, sequence) {
try {
const states = await apiDefinitionsAddable(this.definitions, modes);
@@ -422,6 +429,10 @@ class Display {
}
}
+ get firstExpressionIndex() {
+ return this.options.general.resultOutputMode === 'merge' ? 0 : -1;
+ }
+
static clozeBuild(sentence, source) {
const result = {
sentence: sentence.text.trim()