Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Nova Palestina

Função para trocar imagens com horário programado (minutos)

Recommended Posts

Estou com esse código que troca a imagem de acordo com a hora programada. No entanto ele está programado para mudar de hora em hora. Gostaria de fazer uma alteração para que ele possa em alguns dias mudar a imagem de meia em meia hora também. Assim ao invés de um intervalo de 10 as 11 por exemplo, teríamos um de 10h às 10h30 e um de 10h30 às 11h. Como fazer? Já pesquisei no Google e entrei nuns 10 sites, mas ninguém responde satisfatoriamente.

 

Segue o código:

 

<script>

function rodarpgmradio(){
var now = new Date();
var dia = now.getDay();
var hora = now.getHours();
var minutos = now.getMinutes();
switch (dia){

case 0: //domingo
if(hora >= 0 && hora < 1){ document.write('<img src="fig00.gif">');}
if(hora >= 1 && hora < 2){ document.write('<img src="fig01.gif">');}
if(hora >= 2 && hora < 3){ document.write('<img src="fig02.gif">');}
if(hora >= 3 && hora < 4){ document.write('<img src="fig01.gif">');}
if(hora >= 4 && hora < 5){ document.write('<img src="fig04.gif">');}
if(hora >= 5 && hora < 6){ document.write('<img src="fig05.gif">');}
if(hora >= 6 && hora < 7){ document.write('<img src="fig06.gif">');}
if(hora >= 7 && hora < 8){ document.write('<img src="fig07.gif">');}
if(hora >= 8 && hora < 9){ document.write('<img src="fig08.gif">');}
if(hora >= 9 && hora < 10){ document.write('<img src="fig09.gif">');}
if(hora >= 10 && hora < 11){ document.write('<img src="fig10.gif">');}
if(hora >= 11 && hora < 12){ document.write('<img src="fig11.gif">');}
if(hora >= 12 && hora < 13){ document.write('<img src="fig12.gif">');}
if(hora >= 13 && hora < 14){ document.write('<img src="fig13.gif">');}
if(hora >= 14 && hora < 15){ document.write('<img src="fig14.gif">');}
if(hora >= 15 && hora < 16){ document.write('<img src="fig15.gif">');}
if(hora >= 16 && hora < 17){ document.write('<img src="fig16.gif">');}
if(hora >= 17 && hora < 18){ document.write('<img src="fig17.gif">');}
if(hora >= 18 && hora < 19){ document.write('<img src="fig18.gif">');}
if(hora >= 19 && hora < 20){ document.write('<img src="fig19.gif">');}
if(hora >= 20 && hora < 21){ document.write('<img src="fig01.gif">');}
if(hora >= 21 && hora < 22){ document.write('<img src="fig01.gif">');}
if(hora >= 22 && hora < 23){ document.write('<img src="fig01.gif">');}
if(hora >= 23 ){ document.write('<img src="fig23.gif">');}
break

case 1: //segunda
if(hora >= 0 && hora < 1){ document.write('<img src="fig00.gif">');}
if(hora >= 1 && hora < 2){ document.write('<img src="fig01.gif">');}
if(hora >= 2 && hora < 3){ document.write('<img src="fig02.gif">');}
if(hora >= 3 && hora < 4){ document.write('<img src="fig01.gif">');}
if(hora >= 4 && hora < 5){ document.write('<img src="fig01.gif">');}
if(hora >= 5 && hora < 6){ document.write('<img src="fig01.gif">');}
if(hora >= 6 && hora < 7){ document.write('<img src="fig06.gif">');}
if(hora >= 7 && hora < 8){ document.write('<img src="fig01.gif">');}
if(hora >= 8 && hora < 9){ document.write('<img src="fig08.gif">');}
if(hora >= 9 && hora < 10){ document.write('<img src="fig09.gif">');}
if(hora >= 10 && hora < 11){ document.write('<img src="fig10.gif">');}
if(hora >= 11 && hora < 12){ document.write('<img src="fig11.gif">');}
if(hora >= 12 && hora < 13){ document.write('<img src="fig12.gif">');}
if(hora >= 13 && hora < 14){ document.write('<img src="fig13.gif">');}
if(hora >= 14 && hora < 15){ document.write('<img src="fig14.gif">');}
if(hora >= 15 && hora < 16){ document.write('<img src="fig15.gif">');}
if(hora >= 16 && hora < 17){ document.write('<img src="fig16.gif">');}
if(hora >= 17 && hora < 18){ document.write('<img src="fig17.gif">');}
if(hora >= 18 && hora < 19){ document.write('<img src="fig18.gif">');}
if(hora >= 19 && hora < 20){ document.write('<img src="fig01.gif">');}
if(hora >= 20 && hora < 21){ document.write('<img src="fig20.gif">');}
if(hora >= 21 && hora < 22){ document.write('<img src="fig21.gif">');}
if(hora >= 22 && hora < 23){ document.write('<img src="fig22.gif">');}
if(hora >= 23 ){ document.write('<img src="fig23.gif">');}
break

case 2: //terça
if(hora >= 0 && hora < 1){ document.write('<img src="fig00.gif">');}
if(hora >= 1 && hora < 2){ document.write('<img src="fig01.gif">');}
if(hora >= 2 && hora < 3){ document.write('<img src="fig02.gif">');}
if(hora >= 3 && hora < 4){ document.write('<img src="fig01.gif">');}
if(hora >= 4 && hora < 5){ document.write('<img src="fig01.gif">');}
if(hora >= 5 && hora < 6){ document.write('<img src="fig01.gif">');}
if(hora >= 6 && hora < 7){ document.write('<img src="fig06.gif">');}
if(hora >= 7 && hora < 8){ document.write('<img src="fig01.gif">');}
if(hora >= 8 && hora < 9){ document.write('<img src="fig08.gif">');}
if(hora >= 9 && hora < 10){ document.write('<img src="fig09.gif">');}
if(hora >= 10 && hora < 11){ document.write('<img src="fig10.gif">');}
if(hora >= 11 && hora < 12){ document.write('<img src="fig11.gif">');}
if(hora >= 12 && hora < 13){ document.write('<img src="fig12.gif">');}
if(hora >= 13 && hora < 14){ document.write('<img src="fig13.gif">');}
if(hora >= 14 && hora < 15){ document.write('<img src="fig14.gif">');}
if(hora >= 15 && hora < 16){ document.write('<img src="fig15.gif">');}
if(hora >= 16 && hora < 17){ document.write('<img src="fig16.gif">');}
if(hora >= 17 && hora < 18){ document.write('<img src="fig17.gif">');}
if(hora >= 18 && hora < 19){ document.write('<img src="fig18.gif">');}
if(hora >= 19 && hora < 20){ document.write('<img src="fig01.gif">');}
if(hora >= 20 && hora < 21){ document.write('<img src="fig20.gif">');}
if(hora >= 21 && hora < 22){ document.write('<img src="fig21.gif">');}
if(hora >= 22 && hora < 23){ document.write('<img src="fig22.gif">');}
if(hora >= 23 ){ document.write('<img src="fig01.gif">');}
break

case 3: //quarta
if(hora >= 0 && hora < 1){ document.write('<img src="fig00.gif">');}
if(hora >= 1 && hora < 2){ document.write('<img src="fig01.gif">');}
if(hora >= 2 && hora < 3){ document.write('<img src="fig02.gif">');}
if(hora >= 3 && hora < 4){ document.write('<img src="fig01.gif">');}
if(hora >= 4 && hora < 5){ document.write('<img src="fig01.gif">');}
if(hora >= 5 && hora < 6){ document.write('<img src="fig01.gif">');}
if(hora >= 6 && hora < 7){ document.write('<img src="fig06.gif">');}
if(hora >= 7 && hora < 8){ document.write('<img src="fig01.gif">');}
if(hora >= 8 && hora < 9){ document.write('<img src="fig08.gif">');}
if(hora >= 9 && hora < 10){ document.write('<img src="fig09.gif">');}
if(hora >= 10 && hora < 11){ document.write('<img src="fig10.gif">');}
if(hora >= 11 && hora < 12){ document.write('<img src="fig11.gif">');}
if(hora >= 12 && hora < 13){ document.write('<img src="fig12.gif">');}
if(hora >= 13 && hora < 14){ document.write('<img src="fig13.gif">');}
if(hora >= 14 && hora < 15){ document.write('<img src="fig14.gif">');}
if(hora >= 15 && hora < 16){ document.write('<img src="fig15.gif">');}
if(hora >= 16 && hora < 17){ document.write('<img src="fig16.gif">');}
if(hora >= 17 && hora < 18){ document.write('<img src="fig17.gif">');}
if(hora >= 18 && hora < 19){ document.write('<img src="fig18.gif">');}
if(hora >= 19 && hora < 20){ document.write('<img src="fig01.gif">');}
if(hora >= 20 && hora < 21){ document.write('<img src="fig20.gif">');}
if(hora >= 21 && hora < 22){ document.write('<img src="fig21.gif">');}
if(hora >= 22 && hora < 23){ document.write('<img src="fig22.gif">');}
if(hora >= 23 ){ document.write('<img src="fig23.gif">');}
break

case 4: //quinta
if(hora >= 0 && hora < 1){ document.write('<img src="fig00.gif">');}
if(hora >= 1 && hora < 2){ document.write('<img src="fig01.gif">');}
if(hora >= 2 && hora < 3){ document.write('<img src="fig02.gif">');}
if(hora >= 3 && hora < 4){ document.write('<img src="fig01.gif">');}
if(hora >= 4 && hora < 5){ document.write('<img src="fig01.gif">');}
if(hora >= 5 && hora < 6){ document.write('<img src="fig01.gif">');}
if(hora >= 6 && hora < 7){ document.write('<img src="fig06.gif">');}
if(hora >= 7 && hora < 8){ document.write('<img src="fig01.gif">');}
if(hora >= 8 && hora < 9){ document.write('<img src="fig08.gif">');}
if(hora >= 9 && hora < 10){ document.write('<img src="fig09.gif">');}
if(hora >= 10 && hora < 11){ document.write('<img src="fig10.gif">');}
if(hora >= 11 && hora < 12){ document.write('<img src="fig11.gif">');}
if(hora >= 12 && hora < 13){ document.write('<img src="fig12.gif">');}
if(hora >= 13 && hora < 14){ document.write('<img src="fig13.gif">');}
if(hora >= 14 && hora < 15){ document.write('<img src="fig14.gif">');}
if(hora >= 15 && hora < 16){ document.write('<img src="fig15.gif">');}
if(hora >= 16 && hora < 17){ document.write('<img src="fig16.gif">');}
if(hora >= 17 && hora < 18){ document.write('<img src="fig17.gif">');}
if(hora >= 18 && hora < 19){ document.write('<img src="fig18.gif">');}
if(hora >= 19 && hora < 20){ document.write('<img src="fig01.gif">');}
if(hora >= 20 && hora < 21){ document.write('<img src="fig20.gif">');}
if(hora >= 21 && hora < 22){ document.write('<img src="fig21.gif">');}
if(hora >= 22 && hora < 23){ document.write('<img src="fig22.gif">');}
if(hora >= 23 ){ document.write('<img src="fig23.gif">');}
break

case 5: //sexta
if(hora >= 0 && hora < 1){ document.write('<img src="fig00.gif">');}
if(hora >= 1 && hora < 2){ document.write('<img src="fig01.gif">');}
if(hora >= 2 && hora < 3){ document.write('<img src="fig02.gif">');}
if(hora >= 3 && hora < 4){ document.write('<img src="fig01.gif">');}
if(hora >= 4 && hora < 5){ document.write('<img src="fig01.gif">');}
if(hora >= 5 && hora < 6){ document.write('<img src="fig01.gif">');}
if(hora >= 6 && hora < 7){ document.write('<img src="fig06.gif">');}
if(hora >= 7 && hora < 8){ document.write('<img src="fig01.gif">');}
if(hora >= 8 && hora < 9){ document.write('<img src="fig08.gif">');}
if(hora >= 9 && hora < 10){ document.write('<img src="fig09.gif">');}
if(hora >= 10 && hora < 11){ document.write('<img src="fig10.gif">');}
if(hora >= 11 && hora < 12){ document.write('<img src="fig11.gif">');}
if(hora >= 12 && hora < 13){ document.write('<img src="fig12.gif">');}
if(hora >= 13 && hora < 14){ document.write('<img src="fig13.gif">');}
if(hora >= 14 && hora < 15){ document.write('<img src="fig14.gif">');}
if(hora >= 15 && hora < 16){ document.write('<img src="fig15.gif">');}
if(hora >= 16 && hora < 17){ document.write('<img src="fig16.gif">');}
if(hora >= 17 && hora < 18){ document.write('<img src="fig17.gif">');}
if(hora >= 18 && hora < 19){ document.write('<img src="fig18.gif">');}
if(hora >= 19 && hora < 20){ document.write('<img src="fig01.gif">');}
if(hora >= 20 && hora < 21){ document.write('<img src="fig20.gif">');}
if(hora >= 21 && hora < 22){ document.write('<img src="fig21.gif">');}
if(hora >= 22 && hora < 23){ document.write('<img src="fig22.gif">');}
if(hora >= 23 ){ document.write('<img src="fig23.gif">');}
break

case 6: //sábado
if(hora >= 0 && hora < 1){ document.write('<img src="fig00.gif">');}
if(hora >= 1 && hora < 2){ document.write('<img src="fig01.gif">');}
if(hora >= 2 && hora < 3){ document.write('<img src="fig02.gif">');}
if(hora >= 3 && hora < 4){ document.write('<img src="fig01.gif">');}
if(hora >= 4 && hora < 5){ document.write('<img src="fig04.gif">');}
if(hora >= 5 && hora < 6){ document.write('<img src="fig05.gif">');}
if(hora >= 6 && hora < 7){ document.write('<img src="fig06.gif">');}
if(hora >= 7 && hora < 8){ document.write('<img src="fig07.gif">');}
if(hora >= 8 && hora < 9){ document.write('<img src="fig08.gif">');}
if(hora >= 9 && hora < 10){ document.write('<img src="fig09.gif">');}
if(hora >= 10 && hora < 11){ document.write('<img src="fig10.gif">');}
if(hora >= 11 && hora < 12){ document.write('<img src="fig11.gif">');}
if(hora >= 12 && hora < 13){ document.write('<img src="fig11.gif">');}
if(hora >= 13 && hora < 14){ document.write('<img src="fig13.gif">');}
if(hora >= 14 && hora < 15){ document.write('<img src="fig14.gif">');}
if(hora >= 15 && hora < 16){ document.write('<img src="fig01.gif">');}
if(hora >= 16 && hora < 17){ document.write('<img src="fig16.gif">');}
if(hora >= 17 && hora < 18){ document.write('<img src="fig17.gif">');}
if(hora >= 18 && hora < 19){ document.write('<img src="fig01.gif">');}
if(hora >= 19 && hora < 20){ document.write('<img src="fig01.gif">');}
if(hora >= 20 && hora < 21){ document.write('<img src="fig20.gif">');}
if(hora >= 21 && hora < 22){ document.write('<img src="fig01.gif">');}
if(hora >= 22 && hora < 23){ document.write('<img src="fig22.gif">');}
if(hora >= 23 ){ document.write('<img src="fig01.gif">');}
break
}
}
</script>

 

 

Estou com esse código que troca a imagem de acordo com a hora programada. No entanto ele está programado para mudar de hora em hora. Gostaria de fazer uma alteração para que ele possa em alguns dias mudar a imagem de meia em meia hora também. Assim ao invés de um intervalo de 10 as 11 por exemplo, teríamos um de 10h às 10h30 e um de 10h30 às 11h. Como fazer? Já pesquisei no Google e entrei nuns 10 sites, mas ninguém responde satisfatoriamente.

 

Segue o código:

 

<script>

 

function rodarpgmradio(){
var now = new Date();
var dia = now.getDay();
var hora = now.getHours();
var minutos = now.getMinutes();
switch (dia){

case 0: //domingo
if(hora >= 0 && hora < 1){ document.write('<img src="fig00.gif">');}
if(hora >= 1 && hora < 2){ document.write('<img src="fig01.gif">');}
if(hora >= 2 && hora < 3){ document.write('<img src="fig02.gif">');}
if(hora >= 3 && hora < 4){ document.write('<img src="fig01.gif">');}
if(hora >= 4 && hora < 5){ document.write('<img src="fig04.gif">');}
if(hora >= 5 && hora < 6){ document.write('<img src="fig05.gif">');}
if(hora >= 6 && hora < 7){ document.write('<img src="fig06.gif">');}
if(hora >= 7 && hora < 8){ document.write('<img src="fig07.gif">');}
if(hora >= 8 && hora < 9){ document.write('<img src="fig08.gif">');}
if(hora >= 9 && hora < 10){ document.write('<img src="fig09.gif">');}
if(hora >= 10 && hora < 11){ document.write('<img src="fig10.gif">');}
if(hora >= 11 && hora < 12){ document.write('<img src="fig11.gif">');}
if(hora >= 12 && hora < 13){ document.write('<img src="fig12.gif">');}
if(hora >= 13 && hora < 14){ document.write('<img src="fig13.gif">');}
if(hora >= 14 && hora < 15){ document.write('<img src="fig14.gif">');}
if(hora >= 15 && hora < 16){ document.write('<img src="fig15.gif">');}
if(hora >= 16 && hora < 17){ document.write('<img src="fig16.gif">');}
if(hora >= 17 && hora < 18){ document.write('<img src="fig17.gif">');}
if(hora >= 18 && hora < 19){ document.write('<img src="fig18.gif">');}
if(hora >= 19 && hora < 20){ document.write('<img src="fig19.gif">');}
if(hora >= 20 && hora < 21){ document.write('<img src="fig01.gif">');}
if(hora >= 21 && hora < 22){ document.write('<img src="fig01.gif">');}
if(hora >= 22 && hora < 23){ document.write('<img src="fig01.gif">');}
if(hora >= 23 ){ document.write('<img src="fig23.gif">');}
break

case 1: //segunda
if(hora >= 0 && hora < 1){ document.write('<img src="fig00.gif">');}
if(hora >= 1 && hora < 2){ document.write('<img src="fig01.gif">');}
if(hora >= 2 && hora < 3){ document.write('<img src="fig02.gif">');}
if(hora >= 3 && hora < 4){ document.write('<img src="fig01.gif">');}
if(hora >= 4 && hora < 5){ document.write('<img src="fig01.gif">');}
if(hora >= 5 && hora < 6){ document.write('<img src="fig01.gif">');}
if(hora >= 6 && hora < 7){ document.write('<img src="fig06.gif">');}
if(hora >= 7 && hora < 8){ document.write('<img src="fig01.gif">');}
if(hora >= 8 && hora < 9){ document.write('<img src="fig08.gif">');}
if(hora >= 9 && hora < 10){ document.write('<img src="fig09.gif">');}
if(hora >= 10 && hora < 11){ document.write('<img src="fig10.gif">');}
if(hora >= 11 && hora < 12){ document.write('<img src="fig11.gif">');}
if(hora >= 12 && hora < 13){ document.write('<img src="fig12.gif">');}
if(hora >= 13 && hora < 14){ document.write('<img src="fig13.gif">');}
if(hora >= 14 && hora < 15){ document.write('<img src="fig14.gif">');}
if(hora >= 15 && hora < 16){ document.write('<img src="fig15.gif">');}
if(hora >= 16 && hora < 17){ document.write('<img src="fig16.gif">');}
if(hora >= 17 && hora < 18){ document.write('<img src="fig17.gif">');}
if(hora >= 18 && hora < 19){ document.write('<img src="fig18.gif">');}
if(hora >= 19 && hora < 20){ document.write('<img src="fig01.gif">');}
if(hora >= 20 && hora < 21){ document.write('<img src="fig20.gif">');}
if(hora >= 21 && hora < 22){ document.write('<img src="fig21.gif">');}
if(hora >= 22 && hora < 23){ document.write('<img src="fig22.gif">');}
if(hora >= 23 ){ document.write('<img src="fig23.gif">');}
break

case 2: //terça
if(hora >= 0 && hora < 1){ document.write('<img src="fig00.gif">');}
if(hora >= 1 && hora < 2){ document.write('<img src="fig01.gif">');}
if(hora >= 2 && hora < 3){ document.write('<img src="fig02.gif">');}
if(hora >= 3 && hora < 4){ document.write('<img src="fig01.gif">');}
if(hora >= 4 && hora < 5){ document.write('<img src="fig01.gif">');}
if(hora >= 5 && hora < 6){ document.write('<img src="fig01.gif">');}
if(hora >= 6 && hora < 7){ document.write('<img src="fig06.gif">');}
if(hora >= 7 && hora < 8){ document.write('<img src="fig01.gif">');}
if(hora >= 8 && hora < 9){ document.write('<img src="fig08.gif">');}
if(hora >= 9 && hora < 10){ document.write('<img src="fig09.gif">');}
if(hora >= 10 && hora < 11){ document.write('<img src="fig10.gif">');}
if(hora >= 11 && hora < 12){ document.write('<img src="fig11.gif">');}
if(hora >= 12 && hora < 13){ document.write('<img src="fig12.gif">');}
if(hora >= 13 && hora < 14){ document.write('<img src="fig13.gif">');}
if(hora >= 14 && hora < 15){ document.write('<img src="fig14.gif">');}
if(hora >= 15 && hora < 16){ document.write('<img src="fig15.gif">');}
if(hora >= 16 && hora < 17){ document.write('<img src="fig16.gif">');}
if(hora >= 17 && hora < 18){ document.write('<img src="fig17.gif">');}
if(hora >= 18 && hora < 19){ document.write('<img src="fig18.gif">');}
if(hora >= 19 && hora < 20){ document.write('<img src="fig01.gif">');}
if(hora >= 20 && hora < 21){ document.write('<img src="fig20.gif">');}
if(hora >= 21 && hora < 22){ document.write('<img src="fig21.gif">');}
if(hora >= 22 && hora < 23){ document.write('<img src="fig22.gif">');}
if(hora >= 23 ){ document.write('<img src="fig01.gif">');}
break

case 3: //quarta
if(hora >= 0 && hora < 1){ document.write('<img src="fig00.gif">');}
if(hora >= 1 && hora < 2){ document.write('<img src="fig01.gif">');}
if(hora >= 2 && hora < 3){ document.write('<img src="fig02.gif">');}
if(hora >= 3 && hora < 4){ document.write('<img src="fig01.gif">');}
if(hora >= 4 && hora < 5){ document.write('<img src="fig01.gif">');}
if(hora >= 5 && hora < 6){ document.write('<img src="fig01.gif">');}
if(hora >= 6 && hora < 7){ document.write('<img src="fig06.gif">');}
if(hora >= 7 && hora < 8){ document.write('<img src="fig01.gif">');}
if(hora >= 8 && hora < 9){ document.write('<img src="fig08.gif">');}
if(hora >= 9 && hora < 10){ document.write('<img src="fig09.gif">');}
if(hora >= 10 && hora < 11){ document.write('<img src="fig10.gif">');}
if(hora >= 11 && hora < 12){ document.write('<img src="fig11.gif">');}
if(hora >= 12 && hora < 13){ document.write('<img src="fig12.gif">');}
if(hora >= 13 && hora < 14){ document.write('<img src="fig13.gif">');}
if(hora >= 14 && hora < 15){ document.write('<img src="fig14.gif">');}
if(hora >= 15 && hora < 16){ document.write('<img src="fig15.gif">');}
if(hora >= 16 && hora < 17){ document.write('<img src="fig16.gif">');}
if(hora >= 17 && hora < 18){ document.write('<img src="fig17.gif">');}
if(hora >= 18 && hora < 19){ document.write('<img src="fig18.gif">');}
if(hora >= 19 && hora < 20){ document.write('<img src="fig01.gif">');}
if(hora >= 20 && hora < 21){ document.write('<img src="fig20.gif">');}
if(hora >= 21 && hora < 22){ document.write('<img src="fig21.gif">');}
if(hora >= 22 && hora < 23){ document.write('<img src="fig22.gif">');}
if(hora >= 23 ){ document.write('<img src="fig23.gif">');}
break

case 4: //quinta
if(hora >= 0 && hora < 1){ document.write('<img src="fig00.gif">');}
if(hora >= 1 && hora < 2){ document.write('<img src="fig01.gif">');}
if(hora >= 2 && hora < 3){ document.write('<img src="fig02.gif">');}
if(hora >= 3 && hora < 4){ document.write('<img src="fig01.gif">');}
if(hora >= 4 && hora < 5){ document.write('<img src="fig01.gif">');}
if(hora >= 5 && hora < 6){ document.write('<img src="fig01.gif">');}
if(hora >= 6 && hora < 7){ document.write('<img src="fig06.gif">');}
if(hora >= 7 && hora < 8){ document.write('<img src="fig01.gif">');}
if(hora >= 8 && hora < 9){ document.write('<img src="fig08.gif">');}
if(hora >= 9 && hora < 10){ document.write('<img src="fig09.gif">');}
if(hora >= 10 && hora < 11){ document.write('<img src="fig10.gif">');}
if(hora >= 11 && hora < 12){ document.write('<img src="fig11.gif">');}
if(hora >= 12 && hora < 13){ document.write('<img src="fig12.gif">');}
if(hora >= 13 && hora < 14){ document.write('<img src="fig13.gif">');}
if(hora >= 14 && hora < 15){ document.write('<img src="fig14.gif">');}
if(hora >= 15 && hora < 16){ document.write('<img src="fig15.gif">');}
if(hora >= 16 && hora < 17){ document.write('<img src="fig16.gif">');}
if(hora >= 17 && hora < 18){ document.write('<img src="fig17.gif">');}
if(hora >= 18 && hora < 19){ document.write('<img src="fig18.gif">');}
if(hora >= 19 && hora < 20){ document.write('<img src="fig01.gif">');}
if(hora >= 20 && hora < 21){ document.write('<img src="fig20.gif">');}
if(hora >= 21 && hora < 22){ document.write('<img src="fig21.gif">');}
if(hora >= 22 && hora < 23){ document.write('<img src="fig22.gif">');}
if(hora >= 23 ){ document.write('<img src="fig23.gif">');}
break

case 5: //sexta
if(hora >= 0 && hora < 1){ document.write('<img src="fig00.gif">');}
if(hora >= 1 && hora < 2){ document.write('<img src="fig01.gif">');}
if(hora >= 2 && hora < 3){ document.write('<img src="fig02.gif">');}
if(hora >= 3 && hora < 4){ document.write('<img src="fig01.gif">');}
if(hora >= 4 && hora < 5){ document.write('<img src="fig01.gif">');}
if(hora >= 5 && hora < 6){ document.write('<img src="fig01.gif">');}
if(hora >= 6 && hora < 7){ document.write('<img src="fig06.gif">');}
if(hora >= 7 && hora < 8){ document.write('<img src="fig01.gif">');}
if(hora >= 8 && hora < 9){ document.write('<img src="fig08.gif">');}
if(hora >= 9 && hora < 10){ document.write('<img src="fig09.gif">');}
if(hora >= 10 && hora < 11){ document.write('<img src="fig10.gif">');}
if(hora >= 11 && hora < 12){ document.write('<img src="fig11.gif">');}
if(hora >= 12 && hora < 13){ document.write('<img src="fig12.gif">');}
if(hora >= 13 && hora < 14){ document.write('<img src="fig13.gif">');}
if(hora >= 14 && hora < 15){ document.write('<img src="fig14.gif">');}
if(hora >= 15 && hora < 16){ document.write('<img src="fig15.gif">');}
if(hora >= 16 && hora < 17){ document.write('<img src="fig16.gif">');}
if(hora >= 17 && hora < 18){ document.write('<img src="fig17.gif">');}
if(hora >= 18 && hora < 19){ document.write('<img src="fig18.gif">');}
if(hora >= 19 && hora < 20){ document.write('<img src="fig01.gif">');}
if(hora >= 20 && hora < 21){ document.write('<img src="fig20.gif">');}
if(hora >= 21 && hora < 22){ document.write('<img src="fig21.gif">');}
if(hora >= 22 && hora < 23){ document.write('<img src="fig22.gif">');}
if(hora >= 23 ){ document.write('<img src="fig23.gif">');}
break

case 6: //sábado
if(hora >= 0 && hora < 1){ document.write('<img src="fig00.gif">');}
if(hora >= 1 && hora < 2){ document.write('<img src="fig01.gif">');}
if(hora >= 2 && hora < 3){ document.write('<img src="fig02.gif">');}
if(hora >= 3 && hora < 4){ document.write('<img src="fig01.gif">');}
if(hora >= 4 && hora < 5){ document.write('<img src="fig04.gif">');}
if(hora >= 5 && hora < 6){ document.write('<img src="fig05.gif">');}
if(hora >= 6 && hora < 7){ document.write('<img src="fig06.gif">');}
if(hora >= 7 && hora < 8){ document.write('<img src="fig07.gif">');}
if(hora >= 8 && hora < 9){ document.write('<img src="fig08.gif">');}
if(hora >= 9 && hora < 10){ document.write('<img src="fig09.gif">');}
if(hora >= 10 && hora < 11){ document.write('<img src="fig10.gif">');}
if(hora >= 11 && hora < 12){ document.write('<img src="fig11.gif">');}
if(hora >= 12 && hora < 13){ document.write('<img src="fig11.gif">');}
if(hora >= 13 && hora < 14){ document.write('<img src="fig13.gif">');}
if(hora >= 14 && hora < 15){ document.write('<img src="fig14.gif">');}
if(hora >= 15 && hora < 16){ document.write('<img src="fig01.gif">');}
if(hora >= 16 && hora < 17){ document.write('<img src="fig16.gif">');}
if(hora >= 17 && hora < 18){ document.write('<img src="fig17.gif">');}
if(hora >= 18 && hora < 19){ document.write('<img src="fig01.gif">');}
if(hora >= 19 && hora < 20){ document.write('<img src="fig01.gif">');}
if(hora >= 20 && hora < 21){ document.write('<img src="fig20.gif">');}
if(hora >= 21 && hora < 22){ document.write('<img src="fig01.gif">');}
if(hora >= 22 && hora < 23){ document.write('<img src="fig22.gif">');}
if(hora >= 23 ){ document.write('<img src="fig01.gif">');}
break
}
}
</script>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Sim Bergs,

 

Já inseri essa variável (veja no código acima).

 

Mas dentro do código não consigo chamar as imagens. Umas combinações não carregam e a que mais se aproximou foi essa abaixo, pois pelo menos as imagens aparecem:

 

if (hora >= 14 && minutos > 00 || hora <= 14 && minutos < 30){ document.write('<img src="fig1.gif">');}
if (hora >= 14 && minutos > 30 || hora <= 15 && minutos < 00){ document.write('<img src="fig2.gif">');}

 

O problema é que carrega várias imagens nessa combinação. As figs 1 e 2 do exemplo ficam fixas, independente do horário e sempre carrega como terceira imagem a correspondente ao horário no windows.

Compartilhar este post


Link para o post
Compartilhar em outros sites

o problema está na sua condicional.

veja o que está dizendo a suas duas linhas.

No primeiro if:
se hora for maior ou igual a 14 e minutos maior que 0 ou horas for menor ou igual a 14 e minutos menor que 30

obs: se hora for menor ou maior ou igual que 14 a imagem 1 vai aparecer, logo vai aparecer a todo momento.

no segundo if vc fez a mesma coisa vai aparecer sempre as duas primeiras imagens...

vc precisa agrupar as variáveis para não se confundir com os operadores lógicos.

veja este exemplo: modifique os valores de tempo de acordo com o tempo do seu computador.
está testando de 2 em 2 minutos troque para 1 e 1 minuto para ver mais rápido.

http://fiddle.jshell.net/76aCM/

Compartilhar este post


Link para o post
Compartilhar em outros sites

eu vou conseguir usando esse modelo de código que praticamente está pronto? Com document.write e não com imagem.innerHTML?

 

Para isso só precisaria arrumar a condição acima?

 

Isso aqui:

 

if (hora >= 14 && minutos > 00 || hora <= 14 && minutos < 30){ document.write('<img src="fig1.gif">');}
if (hora >= 14 && minutos > 30 || hora <= 15 && minutos < 00){ document.write('<img src="fig2.gif">');}

 

Ficaria como?

 

Dentro de uma lógica de quem ainda está aprendendo ficaria assim:

 

if(hora >= 13 && hora < 14){ document.write('<img src="fig1.gif">');}
if(hora = 14 && minutos >= 01) || (hora = 14 && minutos <= 30){ document.write('<img src="fig2.gif">');}
if(hora = 14 && minutos >= 31) || (hora = 14 && minutos <= 59){ document.write('<img src="fig3.gif">');}

if(hora >= 15 && hora < 16){ document.write('<img src="fig4.gif">');}

ou

 

if(hora >= 13 && hora < 14){ document.write('<img src="fig1.gif">');}
if(hora = 14 && minutos <= 30){ document.write('<img src="fig2.gif">');}
if(hora = 14 && minutos >= 31){ document.write('<img src="fig3.gif">');}

if(hora >= 15 && hora < 16){ document.write('<img src="fig4.gif">');}

mas não carrega nada

 

Desculpe a falta de tato. Ainda estou tentando aprender.

 

Grato pela força!

Compartilhar este post


Link para o post
Compartilhar em outros sites

crie uma variável tempo

 

var tempo = hora+":"+minutos;

 


e depois faça suas condicionais assim:

if(tempo >= "15:30" && tempo < "16:00") {
 
   document.write('<img src="fig1.gif">');
 
} else if(tempo >= "16:00" && tempo < "16:30") {
 
   document.write('<img src="fig2.gif">');
 
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

RAPAZ....simplesmente.... FUNFOU! Valeu!!!!

 

Para quem se deparar com esse tópico e ainda estiver estudando, vai algumas dicas adicionais:

 

Não precisa mudar todo o código para o formato indicado, ele vai reconhecer quando a imagem for com uma hora de duração normalmente.

 

Apenas nas linhas em que contiver minutos coloque no formato recomendado pelo Bergs e é PONTO FINAL na conversa.

 

Mais uma vez valeu!

Compartilhar este post


Link para o post
Compartilhar em outros sites

Fiz esta função, veja se funciona com você:

<script>
//Função para calcular o intervalo 
function intervalo(h_inicial, h_final)
{ 
	var now = new Date();  
	var dia = now.getDay();  
	var hora = now.getHours();  
	var minutos = now.getMinutes();    
	
	h_ini = h_inicial.replace(':', '');
	h_fim =  h_final.replace(':', '');
	
	if(minutos.toString().length==1)
		minutos = '0'+minutos;	
		
	now = parseInt(hora+''+minutos);
	
	if (now>=parseInt(h_ini) && now<=parseInt(h_fim))
		return true;
	return	false;
}

function rodarpgmradio(){  
	var now = new Date();  

	switch (dia){    

	case 6: //domingo  
		if (intervalo('19:00', '19:40'))
			document.write('<img src="./fig1.jpg">');
		else if (intervalo('19:41', '20:00')) 
			document.write('<img src="./fig2.jpg">');
	}
}

//Chamando a imagem
rodarpgmradio();


</script>

Compartilhar este post


Link para o post
Compartilhar em outros sites

casipe,

 

Vou testar o seu código também.Valeu. Ficou bem trabalhado.

 

 

Quanto ao Bergs, eu não vou reabrir o chamado, mas tem uma questão ainda usando a forma que indicou, mas que só notei editando depois.

 

Um intervalo por exemplo: 10h às 10h30 só começa a mostrar a imagem depois das 10h09, ou seja é alguma coisa com relação a digitos decimais, mas não sei o que. Já tentei programar só com 10, com 10:00, com 10:01, com 10:1, mas ele continua mostrando a imagem das 9h às 10h até que dê 10h10.

Compartilhar este post


Link para o post
Compartilhar em outros sites

No meu caso, eu tratei a questão do minuto começar com zero.

 

Ex.: "10:02" no js irá lê "10:2"

 

Na minha função em adicionei um zero para ficar assim: "10:02".

 

Detelhe: na função intervalo(), como parâmetro, você poderá colocar o horário de duas formas: "10:00" ou "1000".

 

Ex.: intervalo("10:00", "1030")

Compartilhar este post


Link para o post
Compartilhar em outros sites

Rapaz, o negócio é o seguinte:

 

O código carrega direitinho boa parte do dia, mas tem alguns problemas que vou citar e gostaria que alguém com mais conhecimento que eu observasse onde posso estar errando:

 


if(hora >= 0 && hora < 1){ document.write('<img src="filmes.gif">');} ...............OK
if(tempo >= "1:01" && tempo < "1:30") { document.write('<img src="fig1.gif">');} ....Carrega dados duplicados das 19:01 às 20:00
if(tempo >= "1:31" && tempo < "2:00") { document.write('<img src="fig2.gif">');} ....Carrega dados duplicados das 19:01 às 20:00
if(tempo >= "2:01" && tempo < "3:00") { document.write('<img src="fig3.gif">');} ...............OK
if(tempo >= "3:01" && tempo < "6:00") { document.write('<img src="fig4.gif">');} ...............OK
if(tempo >= "6:01" && tempo < "7:00") { document.write('<img src="fig5.gif">');} ...............OK
if(tempo >= "7:01" && tempo < "7:30") { document.write('<img src="fig6.gif">');} ...............OK
if(tempo >= "7:31" && tempo < "8:00") { document.write('<img src="fig7.gif">');} ...............OK
if(tempo >= "8:01" && tempo < "9:00") { document.write('<img src="fig8.gif">');} ...............OK
if(tempo >= "9:01" && tempo < "10:00") { document.write('<img src="fig9.gif">');} ....Não carrega nada
if(tempo >= "10:01" && tempo < "10:30") { document.write('<img src="fig10.gif">');}...............OK
if(tempo >= "10:31" && tempo < "11:00") { document.write('<img src="fig11.gif">');}...............OK
if(tempo >= "11:01" && tempo < "11:30") { document.write('<img src="fig12.gif">');} ...............OK
if(tempo >= "11:31" && tempo < "12:00") { document.write('<img src="fig13.gif">');} ...............OK
if(tempo >= "12:01" && tempo < "13:00") { document.write('<img src="fig14.gif">');} ...............OK
if(tempo >= "13:01" && tempo < "14:00") { document.write('<img src="fig15.gif">');} ...............OK
if(tempo >= "14:01" && tempo < "14:30") { document.write('<img src="fig16.gif">');} ...............OK
if(tempo >= "14:31" && tempo < "15:00") { document.write('<img src="fig17.gif">');} ...............OK
if(tempo >= "15:01" && tempo < "15:30") { document.write('<img src="fig18.gif">');} ...............OK
if(tempo >= "15:31" && tempo < "16:00") { document.write('<img src="fig19.gif">');} ...............OK
if(tempo >= "16:01" && tempo < "17:00") { document.write('<img src="fig20.gif">');} ...............OK
if(tempo >= "17:01" && tempo < "17:30") { document.write('<img src="fig21.gif">');} ...............OK
if(tempo >= "17:31" && tempo < "18:00") { document.write('<img src="fig22.gif">');} ...............OK
if(tempo >= "18:01" && tempo < "19:00") { document.write('<img src="fig23.gif">');} ...............OK
if(tempo >= "19:01" && tempo < "20:00") { document.write('<img src="fig24.gif">');} ...............OK
if(tempo >= "20:01" && tempo < "21:00") { document.write('<img src="fig25.gif">');} .... Carrega dados duplicados das 1:31 às 2:00
if(tempo >= "21:01" && tempo < "22:00") { document.write('<img src="fig26.gif">');}.... Carrega dados duplicados das 1:31 às 2:00
if(tempo >= "22:01" && tempo < "23:00") { document.write('<img src="fig27.gif">');}.... Carrega dados duplicados das 1:31 às 2:00
if(hora >= 23 && hora < 0) { document.write('<img src="fig28.gif">');} ...............OK

 

Além desse horários com problemas, há outra questão já mencionada:

 

No intervalo de 1:01 a 1:30 por exemplo, da 1h às 1h09 fica mostrando a figura seguinte (1:30 a 2:00), só a partir de 1h10 é que mostra a figura do intervalo 1:01 a 1:30. Isso acontece em todos os intervalos de meia em meia hora.

 

 

casipe,

 

 

 

para tentar solucionar as questões que mencionei acima tentei tirar o 0 de alguns minutos e até os ":" também como você recomendou, mas nada adiantou. Ele está misturando os horários, carregando alguns duplamente e trocando o início de intervalos de meia em meia hora. Já olhei meu código e não acho o motivo.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Rapaz quebrei a cabeça o dia todo, tirei zero, tirei ponto, apaguei intervalo. O fato é que você corrige um intervalo e zoa outro. Parece um bugzinho do código que não consigo encontrar. Tanto que reabri o tópico, fazendo inclusive um desafio/;

 

quem conseguiria arranjar esses intervalos que aí estão de forma que carreguem uma única imagem exclusiva daquele horário.

 

<script>
function rodarpgmradio(){
var now = new Date();
var dia = now.getDay();
var hora = now.getHours();
var minutos = now.getMinutes();
var tempo = hora+":"+minutos;
switch (dia){

case 1: //segunda
if(tempo >= "0:01" && tempo < "1:00"){ document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/1/brasao.png">');}
if(tempo >= "1:01" && tempo < "1:30") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/2/brasao.png">');}
if(tempo >= "1:31" && tempo < "2:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/3/brasao.png">');}
if(tempo >= "2:01" && tempo < "3:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/4/brasao.png">');}
if(tempo >= "3:01" && tempo < "6:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/5/brasao.png">');}
if(tempo >= "6:01" && tempo < "7:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/6/brasao.png">');}
if(tempo >= "7:01" && tempo < "7:30") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/7/brasao.png">');}
if(tempo >= "7:31" && tempo < "8:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/8/brasao.png">');}
if(tempo >= "8:01" && tempo < "9:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/9/brasao.png">');}
if(tempo >= "9:01" && tempo < "10:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/10/brasao.png">');}
if(tempo >= "10:01" && tempo < "10:30") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/11/brasao.png">');}
if(tempo >= "10:31" && tempo < "11:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/12/brasao.png">');}
if(tempo >= "11:01" && tempo < "11:30") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/13/brasao.png">');}
if(tempo >= "11:31" && tempo < "12:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/14/brasao.png">');}
if(tempo >= "12:01" && tempo < "13:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/15/brasao.png">');}
if(tempo >= "13:01" && tempo < "14:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/16/brasao.png">');}
if(tempo >= "14:01" && tempo < "14:30") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/17/brasao.png">');}
if(tempo >= "14:31" && tempo < "15:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/18/brasao.png">');}
if(tempo >= "15:01" && tempo < "15:30") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/19/brasao.png">');}
if(tempo >= "15:31" && tempo < "16:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/20/brasao.png">');}
if(tempo >= "16:01" && tempo < "17:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/21/brasao.png">');}
if(tempo >= "17:01" && tempo < "17:30") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/22/brasao.png">');}
if(tempo >= "17:31" && tempo < "18:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/23/brasao.png">');}
if(tempo >= "18:01" && tempo < "19:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/24/brasao.png">');}
if(tempo >= "19:01" && tempo < "20:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/25/brasao.png">');}
if(tempo >= "20:01" && tempo < "21:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/26/brasao.png">');}
if(tempo >= "21:01" && tempo < "22:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/27/brasao.png">');}
if(tempo >= "22:01" && tempo < "23:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/28/brasao.png">');}
if(tempo >= "23:01" && tempo < "0:00") { document.write('<img src="http://www.gazetaesportiva.com.br/upload/campeonatos/equipes/29/brasao.png">');}
break

}
}
</script>


</head>

<body>

<script>rodarpgmradio();</script>

 

Só para servir de exemplo coloquei escudos de times de futebol puxados do www.gazetaesportiva.com.br

Fiz apenas a segunda-feira, então se for tentar em outro dia que não hoje, favor mudar lá no exemplo.

 

preciso saber onde estou errando.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Converte todo o tempo para minutos para trabalhar apenas com um tipo de medida de tempo e também só com dados do tipo numero.

 

 var tempo = (hora*60)+(minutos);

agora você calcula quantos minutos dão por exemplo 5:00 horas que são 5*60 + 0 = 300 minutos, teste desse modo.

 

fazendo assim você não vai mais usar "" aspas.

 

exemplo:

if(tempo<= 300 && tempo < 240) {... }

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.