document.addEventListener('DOMContentLoaded', function() { RefreshTitleswonder(); }); function addTimeStamp() { const tstmp = new Date(); return tstmp.getTime(); } function RefreshTitleswonder() { fetch("https://onair.e-radio.gr/whatson/athensparty/wonder/NowOnAir.xml?timestamp=" + addTimeStamp()) .then(response => response.text()) .then(str => new window.DOMParser().parseFromString(str, "text/xml")) .then(ShowTitleArtistwonder); fetch("https://onair.e-radio.gr/whatson/athensparty/wonder/AirPlayNext.xml?timestamp=" + addTimeStamp()) .then(response => response.text()) .then(str => new window.DOMParser().parseFromString(str, "text/xml")) .then(ShowNextSongswonder); fetch("https://onair.e-radio.gr/whatson/athensparty/wonder/AirPlayHistory.xml?timestamp=" + addTimeStamp()) .then(response => response.text()) .then(str => new window.DOMParser().parseFromString(str, "text/xml")) .then(ShowLastSongswonder); } function ShowTitleArtistwonder(xml) { const songs = xml.getElementsByTagName("Song"); for (let song of songs) { const title = song.getAttribute("title"); document.getElementById("wonder_title").innerHTML = title; const artists = song.getElementsByTagName("Artist"); for (let artist of artists) { const name = artist.getAttribute("name"); document.getElementById("wonder_artist").innerHTML = name; } } } function ShowNowPicwonder(txt) { const img = document.getElementById("wonder_pic"); if (txt) { img.src = txt; img.style.display = 'block'; } else { img.src = ''; img.style.display = 'none'; } } function ShowLastSongswonder(xml) { let tmpLastSongs = ""; const songs = xml.getElementsByTagName("Song"); for (let song of songs) { tmpLastSongs += song.getElementsByTagName("Info")[0].getAttribute("StartTime") + " > "; tmpLastSongs += "" + song.getAttribute("title") + " > "; tmpLastSongs += song.getElementsByTagName("Artist")[0].getAttribute("name") + "
"; } document.getElementById("wonder_lastsongs").innerHTML = tmpLastSongs; } function ShowNextSongswonder(xml) { const songs = xml.getElementsByTagName("Song"); let j = 0; for (let song of songs) { if (j === 0) { document.getElementById("wonder_nexttitle").innerHTML = song.getAttribute("title"); document.getElementById("wonder_nextartist").innerHTML = song.getElementsByTagName("Artist")[0].getAttribute("name"); } j++; document.getElementById("nextheader").style.display = 'block'; } } var oRefreshwonder; oRefreshwonder = window.setInterval(RefreshTitleswonder, 50000);