document.addEventListener('DOMContentLoaded', function() {
RefreshTitlesarionkids();
});
function addTimeStamp() {
const tstmp = new Date();
return tstmp.getTime();
}
function RefreshTitlesarionkids() {
fetch("https://onair.e-radio.gr/whatson/arion/arionkids/NowOnAir.xml?timestamp=" + addTimeStamp())
.then(response => response.text())
.then(str => new window.DOMParser().parseFromString(str, "text/xml"))
.then(ShowTitleArtistarionkids);
fetch("https://onair.e-radio.gr/whatson/arion/arionkids/AirPlayNext.xml?timestamp=" + addTimeStamp())
.then(response => response.text())
.then(str => new window.DOMParser().parseFromString(str, "text/xml"))
.then(ShowNextSongsarionkids);
fetch("https://onair.e-radio.gr/whatson/arion/arionkids/AirPlayHistory.xml?timestamp=" + addTimeStamp())
.then(response => response.text())
.then(str => new window.DOMParser().parseFromString(str, "text/xml"))
.then(ShowLastSongsarionkids);
}
function ShowTitleArtistarionkids(xml) {
const songs = xml.getElementsByTagName("Song");
for (let song of songs) {
const title = song.getAttribute("title");
document.getElementById("arionkids_title").innerHTML = title;
const artists = song.getElementsByTagName("Artist");
for (let artist of artists) {
const name = artist.getAttribute("name");
document.getElementById("arionkids_artist").innerHTML = name;
}
}
}
function ShowNowPicarionkids(txt) {
const img = document.getElementById("arionkids_pic");
if (txt) {
img.src = txt;
img.style.display = 'block';
} else {
img.src = '';
img.style.display = 'none';
}
}
function ShowLastSongsarionkids(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("arionkids_lastsongs").innerHTML = tmpLastSongs;
}
function ShowNextSongsarionkids(xml) {
const songs = xml.getElementsByTagName("Song");
let j = 0;
for (let song of songs) {
if (j === 0) {
document.getElementById("arionkids_nexttitle").innerHTML = song.getAttribute("title");
document.getElementById("arionkids_nextartist").innerHTML = song.getElementsByTagName("Artist")[0].getAttribute("name");
}
j++;
document.getElementById("nextheader").style.display = 'block';
}
}
var oRefresharionkids;
oRefresharionkids = window.setInterval(RefreshTitlesarionkids, 50000);