diff options
author | MaZderMind | 2014-12-14 00:35:28 +0100 |
---|---|---|
committer | MaZderMind | 2014-12-14 00:35:28 +0100 |
commit | 1d40a77dfe6b0100bdd53b2da812a97c9353c7eb (patch) | |
tree | b8dc7f21d69f8427596d509d38b5b1f7feddef73 /assets | |
parent | 46732bc4001bc79823eee3cc38ca095643abde14 (diff) |
show silence marker after some time of *tadaa* silence.
Diffstat (limited to 'assets')
-rw-r--r-- | assets/js/lustiges-script.js | 17 |
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 |