Mercurial > code > home > repos > light9
changeset 626:1a2fc3a93b3e
don't poll on the ascoltami page if it's not the visible tab
Ignore-this: 4c9cbccacecc6bd198fe38aa1abef7e6
author | drewp@bigasterisk.com |
---|---|
date | Wed, 15 Jun 2011 05:46:36 +0000 |
parents | ad41fdc33a91 |
children | f0f56076658d |
files | light9/ascoltami/index.html |
diffstat | 1 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/ascoltami/index.html Wed Jun 15 05:32:23 2011 +0000 +++ b/light9/ascoltami/index.html Wed Jun 15 05:46:36 2011 +0000 @@ -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>