Ver Mensaje Individual
  #8 (permalink)  
Antiguo 03/02/2013, 17:05
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: Cambiar mensaje al finalizar

A mi me funciona
Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2.    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <title>titulo</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
  7. <script type="text/javascript">
  8. //<![CDATA[
  9. (function($) {
  10.  
  11.  $.fn.countdown = function(toDate, callback) {
  12.    var handlers = ['seconds', 'minutes', 'hours', 'days', 'weeks', 'daysLeft'];
  13.    
  14.    function delegate(scope, method) {
  15.      return function() { return method.call(scope) }
  16.    }
  17.    
  18.    return this.each(function() {
  19.      // Convert
  20.      if(!(toDate instanceof Date)) {
  21.        if(String(toDate).match(/^[0-9]*$/)) {
  22.          toDate = new Date(toDate);
  23.        } else if( toDate.match(/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{2,4})\s([0-9]{1,2})\:([0-9]{2})\:([0-9]{2})/) ||
  24.            toDate.match(/([0-9]{2,4})\/([0-9]{1,2})\/([0-9]{1,2})\s([0-9]{1,2})\:([0-9]{2})\:([0-9]{2})/)
  25.            ) {
  26.          toDate = new Date(toDate);
  27.        } else if(toDate.match(/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{2,4})/) ||
  28.                  toDate.match(/([0-9]{2,4})\/([0-9]{1,2})\/([0-9]{1,2})/)
  29.                  ) {
  30.          toDate = new Date(toDate)
  31.        } else {
  32.          throw new Error("Doesn't seen to be a valid date object or string")
  33.        }
  34.      }
  35.      
  36.      var $this = $(this),
  37.          values = {},
  38.          lasting = {},
  39.          interval = $this.data('countdownInterval'),
  40.          currentDate = new Date(),
  41.          secondsLeft = Math.floor((toDate.valueOf() - currentDate.valueOf()) / 1000);
  42.      
  43.      function triggerEvents() {
  44.        // Evaluate if this node is included in the html
  45.        if($this.closest('html').length === 0) {
  46.          stop(); // Release the memory
  47.          dispatchEvent('removed');
  48.          return;
  49.        }
  50.        // Calculate the time offset
  51.        secondsLeft--;
  52.        if(secondsLeft < 0) {
  53.          secondsLeft = 0;
  54.        }
  55.        lasting = {
  56.          seconds : secondsLeft % 60,
  57.          minutes : Math.floor(secondsLeft / 60) % 60,
  58.          hours   : Math.floor(secondsLeft / 60 / 60) % 24,
  59.          days    : Math.floor(secondsLeft / 60 / 60 / 24),
  60.          weeks   : Math.floor(secondsLeft / 60 / 60 / 24 / 7),
  61.          daysLeft: Math.floor(secondsLeft / 60 / 60 / 24) % 7
  62.        }
  63.        for(var i=0; i<handlers.length; i++) {
  64.          var eventName = handlers[i];
  65.          if(values[eventName] != lasting[eventName]) {
  66.            values[eventName] = lasting[eventName];
  67.            dispatchEvent(eventName);
  68.          }
  69.        }
  70.        if(secondsLeft == 0) {
  71.          stop();
  72.          dispatchEvent('finished');
  73.        }
  74.      }
  75.      triggerEvents();
  76.      
  77.      function dispatchEvent(eventName) {
  78.        var event     = $.Event(eventName);
  79.        event.date    = new Date(new Date().valueOf() + secondsLeft);
  80.        event.value   = values[eventName] || "0";
  81.        event.toDate  = toDate;
  82.        event.lasting = lasting;
  83.        switch(eventName) {
  84.          case "seconds":
  85.          case "minutes":
  86.          case "hours":
  87.            event.value = event.value < 10 ? '0'+event.value.toString() : event.value.toString();
  88.            break;
  89.          default:
  90.            if(event.value) {
  91.              event.value = event.value.toString();
  92.            }
  93.            break;
  94.        }
  95.        callback.call($this, event);
  96.      }
  97.      
  98.      function stop() {
  99.        clearInterval(interval);
  100.      }
  101.  
  102.      function start() {
  103.        $this.data('countdownInterval', setInterval(delegate($this, triggerEvents), 1000));
  104.        interval = $this.data('countdownInterval');
  105.      }
  106.      
  107.      if(interval) stop();
  108.      start();
  109.    });
  110.  }
  111. })(jQuery);
  112. //]]>
  113. <script type="text/javascript">
  114. //<![CDATA[
  115. $(document).ready(function(){
  116.  var d, h, m, s;
  117.  $('div#clock').countdown(new Date(2013, 01, 03,20,01), function(event) {
  118.    var timeFormat = "%d day(s) %h:%m:%s"
  119.        $this = $(this);
  120.    switch(event.type) {
  121.      case "days":
  122.        d = event.value;
  123.        break;
  124.      case "hours":
  125.        h = event.value;
  126.        break;
  127.      case "minutes":
  128.        m = event.value;
  129.        break;
  130.      case "seconds":
  131.        s = event.value;
  132.        break;
  133.      case "finished":
  134.  timeFormat = "tiempo expirado";
  135.        $this.fadeTo('slow', 0.5);
  136.        break;
  137.    }
  138.    // Assemble time format
  139.    if(d > 0) {
  140.      timeFormat = timeFormat.replace(/\%d/, d);
  141.      timeFormat = timeFormat.replace(/\(s\)/, Number(d) == 1 ? '' : 's');
  142.    } else {
  143.      timeFormat = timeFormat.replace(/%d day\(s\)/, '');
  144.    }
  145.    timeFormat = timeFormat.replace(/\%h/, h);
  146.    timeFormat = timeFormat.replace(/\%m/, m);
  147.    timeFormat = timeFormat.replace(/\%s/, s);
  148.    // Display
  149.    
  150.    $this.html(timeFormat);
  151.  
  152.  });
  153. });
  154. //]]>
  155. </script><!-- HTML -->
  156. </head>
  157. <div id="clock"></div>
  158. </body>
  159. </html>

Para tu script Enero = 00, Febrero = 01, etc....
Lo de los milisegundos, no se, no uso esos plugins

SAludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.