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
 
@@ -42,13 +42,13 @@
 
	post: 4
 
    };
 

	
 
    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) {
 
		showCurrentSong(data.song);
 
	    }
 
	    $("#currentTime").text(data.t.toFixed(1));
 
@@ -60,12 +60,13 @@
 
				     max: data.duration});
 
	    if (data.playing != lastPlaying) {
 
		$(".playMode").removeClass("active");
 
		$(data.playing ? "#cmd-play" : "#cmd-stop").addClass("active");
 
		lastPlaying = data.playing;
 
	    }
 
	    doneCallback();
 
	});
 
    }
 
    function showCurrentSong(uri) {
 
	$(".songs div").each(function (i, row) {
 
	    row = $(row);
 
	    if (row.find("button").data("uri") == uri) {
 
@@ -128,17 +129,26 @@
 
		   function (data, status, xhr) {
 
		       pendingSlide = false;
 
		   });
 
	},
 
    });
 
    
 
    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>
 

	
 

	
 
  </body>
0 comments (0 inline, 0 general)