# HG changeset patch # User drewp@bigasterisk.com # Date 1308116796 0 # Node ID 1a2fc3a93b3e3024b645d85359a6baf85e9e8f05 # Parent ad41fdc33a91419425406bfb055a0f7791a2e600 don't poll on the ascoltami page if it's not the visible tab Ignore-this: 4c9cbccacecc6bd198fe38aa1abef7e6 diff -r ad41fdc33a91 -r 1a2fc3a93b3e light9/ascoltami/index.html --- 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(); + }); // ]]>