const RADIO_NAME = 'DemonstraĆ§Ć£o One Page'; const URL_STREAMING = 'https://stm1.ninjascast.com:7000'; const URL_SHOUTCAST = 'http://stm1.ninjascast.com:7000'; const HISTORIC = true; window.onload = function () { getStreamingData1(); setInterval(function () { getStreamingData1(); }, 30000); var coverArt = document.getElementsByClassName('sgcover-album')[0]; coverArt.style.height = coverArt.offsetWidth + 'px'; }; function getStreamingData1() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function () { if (this.readyState === 4 && this.status === 200) { if(this.response.length === 0) { console.log('%cdebug', 'font-size: 22px') } var data = JSON.parse(this.responseText); let song = data.currentSong.replace(/'/g, '\''); currentSong = song.replace(/&/g, '&'); let artist = data.currentArtist.replace(/'/g, '\''); currentArtist = artist.replace(/&/g, '&'); let foto = data.currentFoto; currentFoto = foto; // Change the title document.title = RADIO_NAME + ' | ' + currentSong + ' - ' + currentArtist; if (document.getElementById('currentSong').innerHTML !== song) { refreshPrograma(currentSong, currentArtist, currentFoto); for (var i = 0; i < 2; i++) { refreshProximos(data.songHistory[i], i); } } } }; var d = new Date(); xhttp.open('GET', 'https://pbr-def.srvsite.com/template/onepage1/api.php?t=' + d.getTime() +'&tipo=8039', true); xhttp.send(); }; function refreshPrograma(song = '', artist, foto) { var coverArt = document.getElementById('currentCoverArt'); if(foto) { var urlCoverArt = foto; } else { var urlCoverArt = 'https://modelo05.ninjashost.com.br/arquivos/8039/logo_face-8039-20200714093524.jpg'; } coverArt.style.backgroundImage = 'url(' + urlCoverArt + ')'; document.getElementById('currentSong').innerHTML = song; document.getElementById('currentArtist').innerHTML = artist; setTimeout(function () { coverArt.className = ''; }, 8000); }; function refreshProximos(info, n) { var $historicDiv = document.querySelectorAll('#historicSong article'); var $songName = document.querySelectorAll('#historicSong article .music-info .song'); var $artistName = document.querySelectorAll('#historicSong article .music-info .artist'); var foto = info.foto; if(foto) { var urlCoverArt = foto; } else { var urlCoverArt = 'https://modelo05.ninjashost.com.br/arquivos/8039/logo_face-8039-20200714093524.jpg'; } if(info.song == 'semprograma') { $('.historic').hide(); $songName[n].innerHTML = 'Sem programação'; $artistName[n].innerHTML = 'no momento'; document.querySelectorAll('#historicSong article .cover-historic')[n].style.backgroundImage = 'url(' + urlCoverArt + ')'; } else { $('.historic').show(); var music = info.song.replace(/'/g, '\''); var songHist = music.replace(/&/g, '&'); var artist = info.artist.replace(/'/g, '\''); var artistHist = artist.replace(/&/g, '&'); $songName[n].innerHTML = songHist; $artistName[n].innerHTML = artistHist; document.querySelectorAll('#historicSong article .cover-historic')[n].style.backgroundImage = 'url(' + urlCoverArt + ')'; } setTimeout(function () { for (var j = 0; j < 2; j++) { $historicDiv[j].classList.remove('animated'); $historicDiv[j].classList.remove('slideInRight'); } }, 2000); $historicDiv[n].classList.add('animated'); $historicDiv[n].classList.add('slideInRight'); };