function addTimeStamp() { const tstmp = new Date(); return tstmp.getTime(); } function velvetfm_RefreshTitleArtist() { const xhr = new XMLHttpRequest(); const url = "https://onair.e-radio.gr/whatson/athensparty/velvet/NowOnAir.xml?timestamp=" + addTimeStamp(); xhr.open("GET", url, true); xhr.responseType = "document"; xhr.onload = function() { if (xhr.status >= 200 && xhr.status < 300) { velvetfm_ShowTitleArtist(xhr.responseXML); } }; xhr.send(); } function velvetfm_ShowTitleArtist(xml) { const songs = xml.getElementsByTagName("Song"); for (let i = 0; i < songs.length; i++) { document.getElementById("velvetfmTitle").innerHTML = songs[i].getAttribute("title"); } const artists = xml.getElementsByTagName("Artist"); for (let i = 0; i < artists.length; i++) { document.getElementById("velvetfmArtist").innerHTML = artists[i].getAttribute("name"); } } var oRefreshvelvetfm = window.setInterval(velvetfm_RefreshTitleArtist, 50000); // Adding an event listener for script load document.addEventListener('scriptLoaded', function() { velvetfm_RefreshTitleArtist(); });