var lastSong=''; var lastTitle=''; var lastArtist='' var currArtist=''; var tmpLastSongs=''; $(document).ready(function() { RefreshTitles(); }); function addTimeStamp(){ tstmp = new Date(); return tstmp.getTime(); } function RefreshTitles() { $.ajax({ type: "GET", url: "/whatson/cityfm/NowOnAir.xml?timestamp="+addTimeStamp(), dataType: "xml", success: ShowTitleArtist }); } function ShowTitleArtist(xml) { $(xml).find("Song").each(function() { $("#theTitle").html($(this).attr("title")); $(xml).find("Artist").each(function() { $("#theArtist").html($(this).attr("name")); currArtist = $(this).attr("name"); }); if ($(this).attr("title")!=lastTitle){ lastSong = lastTitle+' - '+lastArtist; tmpLastSongs = " > "+lastSong+"
"+tmpLastSongs; if (lastTitle!=''){$("#theLastsongs").html(tmpLastSongs);} lastTitle = $(this).attr("title"); lastArtist = currArtist; } }); } var oRefresh; oRefresh = window.setInterval("RefreshTitles()", 50000);