Buenas, me he descargado una cms y entonces me encuentro con esto.
Código:
<script type="text/javascript">
var javascript_countdown = function () {
var time_left = 10; //number of seconds for countdown
var output_element_id = 'jstimer';
var keep_counting = 1;
function countdown() {
if(time_left < 2) {
keep_counting = 0;
}
time_left = time_left - 1;
}
function add_leading_zero(n) {
if(n.toString().length < 2) {
return '0' + n;
} else {
return n;
}
}
function format_output() {
var seconds;
seconds = time_left % 60;
seconds = add_leading_zero( seconds );
return seconds;
}
function show_time_left() {
document.getElementById(output_element_id).innerHTML = format_output();//time_left;
}
function no_time_left() {
location.href='client';
//document.getElementById(output_element_id).innerHTML = no_time_left_message;
}
return {
count: function () {
countdown();
show_time_left();
},
timer: function () {
javascript_countdown.count();
if(keep_counting) {
setTimeout("javascript_countdown.timer();", 1000);
} else {
no_time_left();
}
},
init: function (t, element_id) {
time_left = t;
output_element_id = element_id;
javascript_countdown.timer();
}
};
}();
function CastVote() {
javascript_countdown.init(5, 'jstimer');
$('.Votar').fadeOut('slow');
$('.CuentaAtras').fadeIn('slow');
//location.href='me';
}
</script>
No tengo ni idea de que sirve, no se nada de javascript.
Por lo menos díganme que hace cada cosa o que puede hacer! Gracias