Kahtlane FM web page
http://kahtlane.eu
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.3 KiB
56 lines
1.3 KiB
7 years ago
|
function update(){
|
||
|
var xhttp = new XMLHttpRequest();
|
||
|
xhttp.onreadystatechange = function() {
|
||
|
if (xhttp.readyState == 4 && xhttp.status == 200) {
|
||
|
var json_text = xhttp.responseText;
|
||
|
var json_obj = JSON.parse(json_text);
|
||
|
var playing = '';
|
||
|
var first = getFirstPlaying(json_obj);
|
||
|
if (first == null) {}
|
||
|
else if (first.artist != undefined) {
|
||
|
playing = first.artist + ' - ';
|
||
|
}
|
||
|
playing += first.title;
|
||
|
var nowPlaying = playing;
|
||
|
update_field('on-air', playing);
|
||
|
update_listeners(json_obj);
|
||
|
}
|
||
|
};
|
||
|
xhttp.open("GET", "http://kahtlane.eu:8000/status-json.xsl", true);
|
||
|
xhttp.send();
|
||
|
}
|
||
|
|
||
|
function update_field(field, data){
|
||
|
document.getElementById(field).innerHTML = data;
|
||
|
return 'ok';
|
||
|
}
|
||
|
|
||
|
function update_listeners(json_obj){
|
||
|
var nowPlaying = getFirstPlaying(json_obj);
|
||
|
update_field('listeners1', nowPlaying.listeners);
|
||
|
}
|
||
|
|
||
|
function autoupdate(){
|
||
|
update();
|
||
|
setInterval(function(){ update(); }, 30000);
|
||
|
}
|
||
|
|
||
|
function change_bg(id){
|
||
|
document.body.style.backgroundImage = "url('http://i.imgur.com/" + id + ".jpg')";
|
||
|
}
|
||
|
|
||
|
function reset_bg(){
|
||
|
document.body.style.backgroundImage = "url('http://i.imgur.com/BkSL2KJ.png')";
|
||
|
}
|
||
|
|
||
|
function getFirstPlaying(jsonObj){
|
||
|
var sources = jsonObj.icestats.source;
|
||
|
for(o=0; o < sources.length; o++) {
|
||
|
if (sources[o].title != undefined) {
|
||
|
return sources[o];
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|