Ver Mensaje Individual
  #7 (permalink)  
Antiguo 04/09/2008, 15:36
juliorjulior
 
Fecha de Ingreso: septiembre-2008
Mensajes: 7
Antigüedad: 16 años, 5 meses
Puntos: 0
Respuesta: aporte: programacion secuencial

Hola David,

os mando con lo que estoy trabajando. He quitado todo lo que estaba probando porque revisando la ejecucion con firefox (firebug) me fallaba. Ahora solo calcula una cuenta atras y no se como cambiar la logica.
He probado incluyendo las siguientes llamadas despues de showCountDown() en la funcion startTimer3h pero no funciona.

muchas gracias.

julior )

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Temporizador de cuenta atrás</title>
<style type="text/css">
<!--
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #777777;
margin: 0;
padding: 0;
text-align: center;
color: #000000;
}
#contenedor {
margin-top: 60px;
width:100%;
margin: 0 auto;
}
#formulario {
height:auto;
width:auto;
}
#formDigitos {
font-size: 500%; /*1800 es el valor final posible */
font-style: normal;
font-family: LED, LEDFont, LcdD;
text-align:center;
/*font-weight:bold;*/
font-stretch: expanded;
/* color: #EDFEFE;*/
/*color: #F0F8FF;*/
color: #c3c3c3;
/*font-weight: bolder;*/
background-color: transparent;
border-color: transparent;
border: 0;
width:500;
height:280;
}

</style>
<script languaje="JavaScript">
<!--
var running = false
var endTime = null
var timerID = null
// var showhour = true
var showhour = false // ahora asi para probar 20

//calculos de milisegundos para calcular horas y minutos
var unMinuto = 60 * 1000
var unaHora = unMinuto * 60

function startTimer3h() {

running = true
now = new Date()
now = now.getTime()


endTime = now + (1000 * 10) //prueba
showCountDown()
}

function showCountDown() {
var now = new Date()
now = now.getTime()

if (endTime - now <= 0) {
stopTimer()
alert ("Fin de la cuenta atrás...")
} else {
var delta = new Date(endTime - now)
var theHor = delta.getHours()
var theMin = delta.getMinutes()
var theSec = delta.getSeconds()

if (!showhour) {
var theTime = theMin
} else {
var theTime = theHor
theTime += ((theMin < 10) ? ":0": ":") + theMin
}
theTime += ((theSec < 10) ? ":0": ":") + theSec

document.forms[0].timerDisplay.value = theTime
if (running) {
timerID = setTimeout("showCountDown()",1000)
}
}
}

function stopTimer() {
// alert ("vamos a parar...")
clearTimeout(timerID)
running = false
document.forms[0].timerDisplay.value = "00:00"
}
//-->
</script>

</head>

<body>
<div id="contenedor">
<h3>Cuenta atrás 10 segundos + 5 segundos + 10 segundos</h3></br>
<form id="formulario">
<input type="button" name="startTime" value="Comenzar" onClick="startTimer3h()">
<input type="button" name="clearTime" value="borrar contador" onClick="stopTimer()"></br></br>
<input size="3" id="formDigitos" type="text" name="timerDisplay" value=""> </br></br>

</form>

<!-- FIN id="contenedor">--></div>



</body>
</html>