aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed
diff options
context:
space:
mode:
authorguidocella <guidocella91@gmail.com>2017-12-16 19:56:53 +0100
committerguidocella <guidocella91@gmail.com>2017-12-16 19:56:53 +0100
commit15b93060c76ee4d59eb8ef90f6e1f8dea4c34ac9 (patch)
tree7c0d664473c8472661b9c41c63eb7e5fd01d9706 /ext/mixed
parenta17e84de83e3f8750d41acf942c4fe476230d83a (diff)
Add option to play audio automatically
Diffstat (limited to 'ext/mixed')
-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()