$(document).ready(function() { RefreshTitles(); }); function addTimeStamp(){ tstmp = new Date(); return tstmp.getTime(); } function RefreshTitles() { $.ajax({ type: "GET", url: "/whatson/sferikos/NowOnAir.xml?timestamp="+addTimeStamp(), dataType: "xml", success: ShowTitleArtist }); $.ajax({ type: "GET", url: "/whatson/sferikos/AirPlayNext.xml?timestamp="+addTimeStamp(), dataType: "xml", success: ShowNextSongs }); $.ajax({ type: "GET", url: "/whatson/sferikos/AirPlayHistory.xml?timestamp="+addTimeStamp(), dataType: "xml", success: ShowLastSongs }); } function ShowTitleArtist(xml) { $(xml).find("Song").each(function() { $("#theTitle").html($(this).attr("title")); $(xml).find("Artist").each(function() { $("#theArtist").html($(this).attr("name")); }); }); } function ShowLastSongs(xml) { var tmpLastSongs=""; $(xml).find("Song").each(function() { tmpLastSongs = $(this).find("Artist").attr("name")+ "
"+tmpLastSongs; tmpLastSongs = "" + $(this).attr("title") + " >"+tmpLastSongs; tmpLastSongs = $(this).find("Info").attr("StartTime")+ " > "+tmpLastSongs; }); $("#theLastsongs").html(tmpLastSongs); } function ShowNextSongs(xml) { var j=0; $(xml).find("Song").each(function() { if (j==0 ){ $("#theNextTitle").html( $(this).attr("title") ); $("#theNextArtist").html( $(this).find("Artist").attr("name") ); } j=j+1; }); } var oRefresh; oRefresh = window.setInterval("RefreshTitles()", 50000);