Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/07/2015, 12:33
radiovoltrega
 
Fecha de Ingreso: julio-2015
Ubicación: Sant Hipòlit de Voltregà
Mensajes: 1
Antigüedad: 8 años, 10 meses
Puntos: 0
Código para radio On Air

Hola buenas,

Estoy intentando crear una pagina web para mi radio y he encontrado este código que funciona correctamente para mostrar si un programa está en este momento en directo:
Código HTML:
// Sun=0 1 2 3 4 5 Sat=6
var DayOfWeek = new Array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');

var DH = new Array (7);
for (d=0; d<7; d++) {
DH[d] = new Array (24);
for (h=0; h<24; h++) { DH[d][h] = ''; }
}

DH[1][19] = "<u>Aires del sur</u><br>19 a 21:45h";
DH[1][20] = "<u>Aires del sur</u><br>19 a 21:45h";

DH[2][18] = "<u>Ona jove</u><br>18 a 19h";

DH[3][17] = "<u>Happy list</u><br>17 a 19h";
DH[3][18] = "<u>Happy list</u><br>17 a 19h";

DH[4][17] = "<u>El pis d'estudiants</u><br>17 a 19h";
DH[4][18] = "<u>El pis d'estudiants</u><br>17 a 19h";

DH[5][21] = "<u>I love roc 34</u><br>21 a 23h";
DH[5][22] = "<u>I love roc 34</u><br>21 a 23h";

DH[6][10] = "<u>El gat petit</u><br>10 a 11h";
DH[6][15] = "<u>Ona jove</u><br>15 a 16h</u><br>Repetició";
DH[6][16] = "<u>Happy list</u><br>16 a 19h</u><br>Repetició";
DH[6][17] = "<u>Happy list</u><br>16 a 19h</u><br>Repetició";
DH[6][19] = "<u>El que + t'agrada</u><br>19 a 21h";
DH[6][21] = "<u>El que + t'agrada</u><br>19 a 21h";

DH[0][09] = "<u>Curts i llargs</u><br>9 a 10h";
DH[0][10] = "<u>A cau d'orella</u><br>10 a 10:45h";
DH[0][11] = "<u>Capsa de música</u><br>11 a 12h";
DH[0][12] = "<u>L'hora del vermut</u><br>12:30 a 13:30h";
DH[0][13] = "<u>L'hora del vermut</u><br>12:30 a 13:30h";
DH[0][19] = "<u>Sabem què volem</u><br>19 a 20h";
DH[0][20] = "<u>La platja</u><br>20 a 21h";

function proximprograma() {
var thedate = new Date();
var dayofweek = thedate.getDay();
var hourofday = thedate.getHours();
// alert(dayofweek+':'+hourofday+'<br />'+DH[dayofweek][hourofday]);
var showOn = DH[dayofweek][hourofday];
if (showOn == '') { showOn = thedate+'\n\nNo Show Scheduled'; }
alert(showOn);
}

function NowON() {
var thedate = new Date();
var dayofweek = thedate.getDay();
var hourofday = thedate.getHours();
var showOn = DH[dayofweek][hourofday];
if (showOn == '') { showOn = '<u>Fórmula 107.8</u>'; }
document.getElementById('NowOn').innerHTML = showOn;

} 
Es un fichero aparte llamado horaris.js y lo incluyo y lo muestro en el archivo html principal:

Código HTML:
<script type="text/javascript" src="./horaris.js"></script>

<div id='NowOn' onClick="NowON()">
									<div>Cargando...</div>
									
								</div> 
Esto funciona bien. El problema es que me gustaría añadir otro apartado que muestre el próximo programa que va a salir al aire.

También, si es possible, me gustaría saber cómo podría hacer que el código también acepte minutos, ya que hay programas que no empiezan en la hora en punto sino que empiezan a y media por ejemplo.

Muchas gracias