aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/js/lustiges-script.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/assets/js/lustiges-script.js b/assets/js/lustiges-script.js
index c70a459..170a15d 100644
--- a/assets/js/lustiges-script.js
+++ b/assets/js/lustiges-script.js
@@ -90,20 +90,25 @@ MediaElementPlayer.prototype.buildsubs = function(player, controls, layers, medi
if(window.io)
return openSocket();
- console.log('load');
$.getScript(host+'socket.io/socket.io.js', openSocket);
}
+ function silence() {
+ $text.hide();
+ $silence.show().animate({opacity: 1, duration: .75});
+ }
+
function openSocket() {
- var hideTimeout;
+ var hideTimeout, silenceTimeout, silenceWait = 15*1000;
var socket = io(host);
socket.on('connect', function() {
$line.animate({opacity: 1}, t);
- console.log('fade');
socket.emit('join', room);
});
+ silenceTimeout = setTimeout(silence, silenceWait);
+
socket.on('line', function(stamp, line, duration) {
if(hideTimeout)
clearTimeout(hideTimeout);
@@ -112,10 +117,14 @@ MediaElementPlayer.prototype.buildsubs = function(player, controls, layers, medi
$text.animate({opacity: 0}, t)
clearTimeout(hideTimeout);
hideTimeout = null;
-
}, duration*1000);
+ if(silenceTimeout)
+ clearTimeout(silenceTimeout);
+
+ silenceTimeout = setTimeout(silence, silenceWait);
+
$text.animate({
opacity: 0