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