function fillJukezone(response) { if($("#volume").slider( "option", "value" ) != response['volume']) { $("#volume").slider( "option", "value", response['volume'] ); } var content = '<table style="width:100%">'; var i=0; $.each(response['streams'], function(k,v) { if(response['nowplaying']==i) content += '<tr><td class="button" onclick="playStream(\''+v+'\')"><b><u>'+k+'</u></b></td></tr>'; else content += '<tr><td class="button" onclick="playStream(\''+v+'\')">'+k+'</td></tr>'; i++; }); content += '</table>'; $("#Jukezone").html(content); } function resetJukezone() { var content = '<table class="box" style="align:center;width:95%;">'; content += '<tr><td width="30%"><h2>Status:</h2></td><td style="color:aa0000">Offline</td></tr>'; content += '</table>'; $("#Jukezone").html(content); } function setVolume(v) { $.getJSON("widgets/Jukezone/ajax.php?volume="+v, function (response) { fillJukezone(response); }); } function playStream(v) { $.getJSON("widgets/Jukezone/ajax.php?play="+v, function (response) { fillJukezone(response); }); } function updateJukezone() { $.getJSON("widgets/Jukezone/ajax.php", function (response) { fillJukezone(response); }); } $(document).ready(function() { addFunctionToMinuteTimer(updateJukezone); resetJukezone(); updateJukezone(); $("#volume").slider(); $("#volume").slider( "option", "animate", true ); $("#volume").slider( "option", "max", 0 ); $("#volume").slider( "option", "max", 100 ); $("#volume").slider( "option", "range", "min" ); $("#volume").slider( "option", "step", 1 ); $("#volume").slider( "option", "value", 0 ); $("#volume").bind( "slidechange", function(event, ui) { setVolume($("#volume").slider( "option", "value")); }); } );