From 1d40a77dfe6b0100bdd53b2da812a97c9353c7eb Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sun, 14 Dec 2014 00:35:28 +0100 Subject: show silence marker after some time of *tadaa* silence. --- assets/js/lustiges-script.js | 17 +++++++++++++---- 1 file 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 -- cgit v1.2.3