Changeset - 1a2fc3a93b3e
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 14 years ago 2011-06-15 05:46:36
drewp@bigasterisk.com
don't poll on the ascoltami page if it's not the visible tab
Ignore-this: 4c9cbccacecc6bd198fe38aa1abef7e6
1 file changed with 13 insertions and 3 deletions:
0 comments (0 inline, 0 general)
light9/ascoltami/index.html
Show inline comments
 
@@ -45,7 +45,7 @@
 
    var currentDuration = 0;
 
    var currentHighlightedSong = "";
 
    var lastPlaying;
 
    function updateCurrent() {
 
    function updateCurrent(doneCallback) {
 
	$.getJSON("time", {}, function (data, status) {
 
	    $("#currentSong").text(data.song);
 
	    if (data.song != currentHighlightedSong) {
 
@@ -63,6 +63,7 @@
 
		$(data.playing ? "#cmd-play" : "#cmd-stop").addClass("active");
 
		lastPlaying = data.playing;
 
	    }
 
	    doneCallback();
 
	});
 
    }
 
    function showCurrentSong(uri) {
 
@@ -131,11 +132,20 @@
 
	},
 
    });
 
    
 
    var raf = window.requestAnimationFrame ||
 
	window.mozRequestAnimationFrame || 
 
	window.webkitRequestAnimationFrame;
 

	
 
    function updateLoop() {
 
	updateCurrent();
 
	setTimeout(updateLoop, 200);
 
	var whenDone = function () {
 
	    setTimeout(function () { 
 
		raf(updateLoop);
 
	    }, 50);
 
	};
 
	updateCurrent(whenDone);
 
    }
 
    updateLoop();
 

	
 
});
 
// ]]>
 
</script>
0 comments (0 inline, 0 general)