Commit 7b15ad5a authored by fred's avatar fred
Browse files

refresh "what's on air" by default, but less often

parent 516b1b90
......@@ -148,8 +148,8 @@ $(function() {
/**** AUDIOPLAYER ****/
/****************************************************/
var timer = null,
interval = 5000;
var timer = null;
var refresh_onair_interval = 25000;
var ticker_interval = null;
/*
//TODO: mini icon version for player, (playpause only)
......@@ -171,10 +171,11 @@ $(function() {
*/
$('#WhatsOnAir').on('load',function(){
var WhatsOnAir = $(this);
$('#RefreshWhatsOnAir').addClass('spinning');
$.getJSON('/onair.json', function(onair) {
WhatsOnAir.fadeOut();
if(onair.data.episode || onair.data.emission){
var onairContainer = $('<span>');
setTimeout(function() { $('#RefreshWhatsOnAir').removeClass('spinning'); }, 5000);
var onairContainer = $('<span>');
if(onair.data.episode || onair.data.emission) {
if(onair.data.emission){
$('<a>',{href:onair.data.emission.url,html:onair.data.emission.title}).appendTo(onairContainer).ajaxifyClick();
}
......@@ -182,31 +183,37 @@ $(function() {
$('<span> - </span>').appendTo(onairContainer);
$('<a>',{href:onair.data.episode.url,html:onair.data.episode.title}).appendTo(onairContainer).ajaxifyClick();
}
WhatsOnAir.empty().append(onairContainer);
} else if (onair.data.nonstop) {
result = onair.data.nonstop.title;
WhatsOnAir.html('<span>' + result + '</span>');
onairContainer = $('<span>' + onair.data.nonstop.title + '</span>');
}
else {
onairContainer = $('<span>Unknown (Probably Non-Stop)</span>');
}
var current_html = WhatsOnAir.html();
var new_html = '<span>' + onairContainer.html() + '</span>';
if (new_html !== current_html) {
WhatsOnAir.fadeOut();
WhatsOnAir.empty().append(onairContainer);
WhatsOnAir.fadeIn();
}
else{WhatsOnAir.html('<span>Unknown (Probably Non-Stop)</span>');}
WhatsOnAir.fadeIn();
});
}).trigger('load');
});
$('#RefreshWhatsOnAir').on('activate',function(e){
$(this).addClass('spinning');
$('#WhatsOnAir').addClass('active');
$('#WhatsOnAir').trigger('load');
timer = setInterval( "$('#WhatsOnAir').trigger('load');", interval);
timer = setInterval( "$('#WhatsOnAir').trigger('load');", refresh_onair_interval);
}).on('deactivate',function(e){
$(this).removeClass('spinning');
$('#WhatsOnAir').removeClass('active');
clearInterval(timer);
}).on('click',function(e){
$(this).toggleClass('spinning');
if($(this).is('.spinning')){
$(this).trigger('activate');
}else{$(this).trigger('deactivate');}
$(this).toggleClass('active');
if($(this).is('.active')){
$(this).trigger('deactivate');
}else{
$(this).trigger('activate');
}
return false;
});
}).trigger('activate');
$("#DirectStreamPanikControler").on('click',function(e) {
e.preventDefault();
var stream = $('#DirectStreamPanik').get(0);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment