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