document.addEventListener('DOMContentLoaded', function() {
RefreshTitlesarionlaikos();
});
function addTimeStamp() {
const tstmp = new Date();
return tstmp.getTime();
}
function RefreshTitlesarionlaikos() {
fetch("https://onair.e-radio.gr/whatson/arion/arionlaikos/NowOnAir.xml?timestamp=" + addTimeStamp())
.then(response => response.text())
.then(str => new window.DOMParser().parseFromString(str, "text/xml"))
.then(ShowTitleArtistarionlaikos);
fetch("https://onair.e-radio.gr/whatson/arion/arionlaikos/AirPlayNext.xml?timestamp=" + addTimeStamp())
.then(response => response.text())
.then(str => new window.DOMParser().parseFromString(str, "text/xml"))
.then(ShowNextSongsarionlaikos);
fetch("https://onair.e-radio.gr/whatson/arion/arionlaikos/AirPlayHistory.xml?timestamp=" + addTimeStamp())
.then(response => response.text())
.then(str => new window.DOMParser().parseFromString(str, "text/xml"))
.then(ShowLastSongsarionlaikos);
}
function ShowTitleArtistarionlaikos(xml) {
const songs = xml.getElementsByTagName("Song");
for (let song of songs) {
const title = song.getAttribute("title");
document.getElementById("arionlaikos_title").innerHTML = title;
const artists = song.getElementsByTagName("Artist");
for (let artist of artists) {
const name = artist.getAttribute("name");
document.getElementById("arionlaikos_artist").innerHTML = name;
}
}
}
function ShowNowPicarionlaikos(txt) {
const img = document.getElementById("arionlaikos_pic");
if (txt) {
img.src = txt;
img.style.display = 'block';
} else {
img.src = '';
img.style.display = 'none';
}
}
function ShowLastSongsarionlaikos(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("arionlaikos_lastsongs").innerHTML = tmpLastSongs;
}
function ShowNextSongsarionlaikos(xml) {
const songs = xml.getElementsByTagName("Song");
let j = 0;
for (let song of songs) {
if (j === 0) {
document.getElementById("arionlaikos_nexttitle").innerHTML = song.getAttribute("title");
document.getElementById("arionlaikos_nextartist").innerHTML = song.getElementsByTagName("Artist")[0].getAttribute("name");
}
j++;
document.getElementById("nextheader").style.display = 'block';
}
}
var oRefresharionlaikos;
oRefresharionlaikos = window.setInterval(RefreshTitlesarionlaikos, 50000);