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