Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/08/2010, 12:07
huaymas
 
Fecha de Ingreso: marzo-2009
Mensajes: 31
Antigüedad: 16 años, 1 mes
Puntos: 0
Información Cuenta atras java script

Hola gente como estan, soy nuevo, estudiante de programacion, yqueria saber si es posible, agragar a el codigo que pongo una punfion para que cuando llegue al momento del evento muestre los dos tiempos de 45 minutos y los 15 minutos de entretiempo. espero me puedan guiar a terminarlo, el codigo no es mio es de un amigo de otra pagina.

Código Javascript:
Ver original
  1. <script type='text/javascript'>
  2. /*
  3. Modificado y recopilado por JoniJnm
  4. http://www.jonijnm.es
  5. */
  6.  
  7. var id;
  8. if (!id) { id = 1; }
  9. else { id++; }
  10.  
  11. document.write("<table border='0' width='100%'>");
  12. document.write("<span><b>· Nombre del evento:</b></span><br>");
  13. document.write("<span><font color='#FF0000'><b>El evento</b></font></span><br>");
  14. document.write("<span><b>· D&iacute;a del evento:</b></span><br>");
  15. document.write("<span id='evento" + id + "'></span>");
  16. document.write("<span><b>· Tiempo Restante:</b></span><br>");
  17. document.write("<span id='contar" + id + "'></span>");
  18. document.write("</table>");
  19. document.write("<p><small><b><a href='http://www.jonijnm.es' style='text-decoration: none'>www.JoniJnm.es</a></b></small></p>");
  20.  
  21. //PON AQUÍ LA FECHA DEL EVENTO, ANO, MES, DIA, HORA, MINUTO Y SEGUNDO
  22. setInterval('contar(2008,07,06,00,01,0,' + id + ')',1000);
  23.  
  24. </script>
  25.  
  26. <script type='text/javascript'>
  27.  
  28. function contar(ayo,mes,dia,hora,minuto,segundo,id) {
  29.  
  30. /*
  31. Autor 1: pepe
  32. http:www.forosdelweb.com/f13/contador-cuenta-atras-356428/#post1357499
  33.  
  34. Autor 2: Chris Meichtry
  35. http:www.mambosphere.com
  36.  
  37. Autor 3 (Modificador y recopilador): JoniJnm
  38. htp://www.jonijnm.es
  39. */
  40.   var dif = dia + ' del ' + mes + ' de ' + ayo + ', a las ' + hora + ':';
  41.   if (minuto < 10) { dif+='0'; }
  42.   dif+=minuto + '<br>';
  43.   document.getElementById('evento' + id).innerHTML=dif
  44.   var a = new Date();
  45.   //hora, minuto,segundo, mes,dia a?o.
  46.   var dif= mktime(hora,minuto,segundo,mes - 1,dia,ayo) - mktime(a.getHours(),a.getMinutes(),a.getSeconds(),a.getMonth(),a.getDate(), a.getFullYear());
  47.   if (dif < 0) { document.getElementById('contar' + id).innerHTML="<font color='#FF0000'>Lleg&oacute; el evento!!</font>"; }
  48.   else {
  49.     dia= Math.floor(dif/60/60/24);  
  50.     hora= Math.floor((dif - dia*60*60*24)/60/60);
  51.     minuto= Math.floor((dif - dia*60*60*24 - hora*60*60)/60);
  52.     segundo= Math.floor(dif - dia*60*60*24 - hora*60*60 - minuto*60);
  53.     var txt = '';
  54.     if (dia > 0) {
  55.         txt=dia+' d&iacute;a';
  56.         if (dia != 1) { txt+='s'; }
  57.         txt+= '<br>';
  58.     }
  59.     if (hora > 0 || dia > 0) {
  60.         txt+=hora+' hora';
  61.         if (hora != 1) { txt+='s'; }
  62.         txt+= '<br>';
  63.     }
  64.     if (minuto > 0 || hora > 0 || dia > 0) {
  65.         txt+=minuto+' minuto';
  66.         if (minuto != 1) { txt+='s'; }
  67.         txt+= '<br>';
  68.     }
  69.     txt+=segundo+' segundo';
  70.     if (segundo != 1) { txt+='s'; }
  71.     document.getElementById('contar' + id).innerHTML=txt;
  72.     }
  73.  
  74. function mktime() {
  75.     // http://kevin.vanzonneveld.net
  76.     // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
  77.     // +   improved by: baris ozdil
  78.     // +      input by: gabriel paderni
  79.     // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
  80.     // +   improved by: FGFEmperor
  81.     // +      input by: Yannoo
  82.     // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
  83.     // *     example 1: mktime( 14, 10, 2, 2, 1, 2008 );
  84.     // *     returns 1: 1201871402
  85.    
  86.     var no, ma = 0, mb = 0, i = 0, d = new Date(), argv = arguments, argc = argv.length;
  87.     d.setHours(0,0,0); d.setDate(1); d.setMonth(1); d.setYear(1972);
  88.  
  89.     var dateManip = {
  90.         0: function(tt){ return d.setHours(tt); },
  91.         1: function(tt){ return d.setMinutes(tt); },
  92.         2: function(tt){ set = d.setSeconds(tt); mb = d.getDate() - 1; return set; },
  93.         3: function(tt){ set = d.setMonth(parseInt(tt)-1); ma = d.getFullYear() - 1972; return set; },
  94.         4: function(tt){ return d.setDate(tt+mb); },
  95.         5: function(tt){ return d.setYear(tt+ma); }
  96.     };
  97.    
  98.     for( i = 0; i < argc; i++ ){
  99.         no = parseInt(argv[i]*1);
  100.         if(no && isNaN(no)){
  101.             return false;
  102.         } else if(no){
  103.             // arg is number, let's manipulate date object
  104.             if(!dateManip[i](no)){
  105.                 // failed
  106.                 return false;
  107.             }
  108.         }
  109.     }
  110.  
  111.     return Math.floor(d.getTime()/1000);
  112. }
  113.  
  114. }
  115. </script>