diff --git a/public/global/nav/bcast.js b/public/global/nav/bcast.js new file mode 100755 index 0000000..780fcda --- /dev/null +++ b/public/global/nav/bcast.js @@ -0,0 +1,83 @@ + +window.onload = function(){ + radioUpdate(); + + function radioUpdate(){ + d3.json(radio_server +"/status-json.xsl") + .timeout(10000) + .get(function(e,d){ + if(e !=undefined){ + console.warn("sin conxion"); + offline();} + else{ + if(d.icestats.source!=undefined){ + if(d.icestats.source.listenurl == webm_listen_url){ + console.log("transmitiendo video"); + onlinev(d); } + else if (d.icestats.source.listenurl == radio_listen_url){ + console.log("transmitiendo radio"); + onliner(d); } + else if (d.icestats.source.listenurl == radiop_listen_url){ + console.log("transmitiendo radio"); + onlinerp(d); } + else { + console.warn("otro canal"); + offline(); }} + else { + console.warn("fuera de lĂ­nea"); + offline(); + } + } }); }; + + + function dataUpdate(){ + d3.json(radio_server+"/status-json.xsl") + .timeout(10000) + .get(function(e,d){ + if(e !=undefined){ console.warn("sin datos radio"); } + else{ + if(d.icestats.source!=undefined){ + if(d.icestats.source.listenurl == listen_url ){ + d3.select("#now").text(d.icestats.source.title); + }}} + + d3.select("#ra").transition().on("end",dataUpdate).delay(60000); +}); +}; + + + function offline(){ + d3.selectAll("article.broadcast").style("display","none") + d3.select("article.broadcast").transition().on("end",radioUpdate).delay(90000); + d3.selectAll("a.radiolink").style("display", "display"); + d3.selectAll("a.radiolinkp").style("display", "none"); + }; + + function onlinev(d){ + d3.selectAll("article.broadcast") + .style("display","block"); + d3.selectAll("article.broadcast,p.broadcast") + .on("click",function(){window.location="bcast";}); + dataUpdate(); +} + function onliner(d){ + d3.selectAll(".broadcast") + .style("display","block"); + d3.selectAll("article.broadcast,p.broadcast") + .on("click",function(){window.location="radio";}); + d3.selectAll("a.radiolink").style("display", "display"); + d3.selectAll("a.radiolinkp").style("display", "none"); + dataUpdate(); +} + function onlinerp(d){ + d3.selectAll(".broadcast") + .style("display","block"); + d3.selectAll("article.broadcast,p.broadcast") + .on("click",function(){window.location="radiop";}); + d3.selectAll("a.radiolinkp").style("display", "display"); + d3.selectAll("a.radiolink").style("display", "none"); + dataUpdate(); +} + + +} diff --git a/public/home/home/bcast.js b/public/home/home/bcast.js index 6bf2a09..4d84773 100755 --- a/public/home/home/bcast.js +++ b/public/home/home/bcast.js @@ -37,7 +37,7 @@ window.onload = function(){ if(e !=undefined){ console.warn("sin datos radio"); } else{ if(d.icestats.source!=undefined){ - if(d.icestats.source.listenurl == listen_url ){ + if(d.icestats.source.listenurl == radio_listen_url ){ d3.select("#now").text(d.icestats.source.title); }}} @@ -58,6 +58,14 @@ window.onload = function(){ .on("click",function(){window.location="bcast";}); dataUpdate(); } + function onliner(d){ + d3.selectAll(".broadcast") + .style("display","block"); + d3.selectAll("article.broadcast,p.broadcast") + .on("click",function(){window.location="radio";}); + dataUpdate(); +} + function onlinerp(d){ d3.selectAll(".broadcast") .style("display","block"); diff --git a/templates/home/home.html.ep b/templates/home/home.html.ep index a0114d6..51e40de 100755 --- a/templates/home/home.html.ep +++ b/templates/home/home.html.ep @@ -66,5 +66,7 @@