JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://www.viaata.com.br/site2/scripts/script.js"></script>
<script src="http://www.viaata.com.br/site2/scripts/jquery.countdown.js"></script>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<link rel="stylesheet" href="http://www.viaata.com.br/site2/css/jquery.countdown.css">
<link rel="stylesheet" href="http://www.viaata.com.br/site2/css/styles.css">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<!-- Our CSS stylesheet file -->
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300" />
<link rel="stylesheet" href="assets/css/styles.css" />
<link rel="stylesheet" href="assets/countdown/jquery.countdown.css" />
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div id="countdown"></div>
<p id="note"></p>
</body>
</html>
JavaScript
/**
* @name jQuery Countdown Plugin
* @author Martin Angelov
* @version 1.0
* @url http://tutorialzine.com/2011/12/countdown-jquery/
* @license MIT License
*/
(function($){
// Number of seconds in every time division
var dias = 24*60*60,
horas = 60*60,
minutos = 60;
// Creating the plugin
$.fn.countdown = function(prop){
var options = $.extend({
callback : function(){},
timestamp : 0
},prop);
var left, d, h, m, s, positions;
// Initialize the plugin
init(this, options);
positions = this.find('.position');
(function tick(){
// Time left
left = Math.floor((options.timestamp - (new Date())) / 1000);
if(left < 0){
left = 0;
}
// Number of days left
d = Math.floor(left / dias);
updateDuo(0, 1, d);
left -= d*dias;
// Number of hours left
h = Math.floor(left / horas);
updateDuo(2, 3, h);
left -= h*horas;
// Number of minutes left
m = Math.floor(left / minutos);
updateDuo(4, 5, m);
left -= m*minutos;
// Number of seconds left
s = left;
updateDuo(6, 7, s);
// Calling an optional user supplied callback
options.callback(d, h, m, s);
// Scheduling another call of this function in 1s
setTimeout(tick, 1000);
})();
// This function updates two digit positions at once
function updateDuo(minor,major,value){
switchDigit(positions.eq(minor),Math.floor(value/10)%10);
switchDigit(positions.eq(major),value%10);
}
...