summaryrefslogtreecommitdiff
path: root/ext/fg/js/float.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/fg/js/float.js
parenta17e84de83e3f8750d41acf942c4fe476230d83a (diff)
parent15b93060c76ee4d59eb8ef90f6e1f8dea4c34ac9 (diff)
Merge pull request #103 from guidocella/play-audio-automatically
Add option to play audio automatically
Diffstat (limited to 'ext/fg/js/float.js')
-rw-r--r--ext/fg/js/float.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js
index ff50483d..1f08702d 100644
--- a/ext/fg/js/float.js
+++ b/ext/fg/js/float.js
@@ -20,6 +20,8 @@
class DisplayFloat extends Display {
constructor() {
super($('#spinner'), $('#definitions'));
+ this.autoPlayAudioTimer = null;
+
$(window).on('message', utilAsync(this.onMessage.bind(this)));
}
@@ -54,6 +56,10 @@ class DisplayFloat extends Display {
this.kanjiShow(definitions, options, context);
},
+ clearAutoPlayTimer: () => {
+ this.clearAutoPlayTimer();
+ },
+
orphaned: () => {
this.onOrphaned();
}
@@ -83,6 +89,18 @@ class DisplayFloat extends Display {
super.onKeyDown(e);
}
}
+
+ autoPlayAudio() {
+ this.clearAutoPlayTimer();
+ this.autoPlayAudioTimer = window.setTimeout(() => super.autoPlayAudio(), 400);
+ }
+
+ clearAutoPlayTimer() {
+ if (this.autoPlayAudioTimer) {
+ window.clearTimeout(this.autoPlayAudioTimer);
+ this.autoPlayAudioTimer = null;
+ }
+ }
}
window.yomichan_display = new DisplayFloat();