1(function ($) { 2 function pad(n) { 3 return (n < 10) ? ("0" + n) : n; 4 } 5 6 $.fn.showclock = function () { 7 var currentDate = new Date(); 8 var fieldDate = $(this).data('date').split('-'); 9 var countType = $(this).data('count-type') || 'down'; 10 11 // Hora por defecto: 12 // - down: final del dÃa 13 // - up: inicio del dÃa 14 var fieldTime = (countType === 'up') ? [0, 0, 0] : [23, 59, 0]; 15 16 // Soporte opcional para data-time="HH:MM:SS" 17 if ($(this).data('time') != undefined) { 18 fieldTime = $(this).data('time').split(':'); 19 } 20 21 var targetDate = new Date( 22 fieldDate[0], 23 fieldDate[1] - 1, 24 fieldDate[2], 25 fieldTime[0], 26 fieldTime[1], 27 fieldTime[2] 28 ); 29 30 var seconds; 31 32 if (countType === 'up') { 33 // Tiempo transcurrido desde la fecha indicada hasta ahora 34 seconds = currentDate.getTime() / 1000 - targetDate.getTime() / 1000; 35 } else { 36 // Tiempo restante desde ahora hasta la fecha indicada 37 seconds = targetDate.getTime() / 1000 - currentDate.getTime() / 1000; 38 } 39 40 var days = 0; 41 var hours = 0; 42 var minutes = 0; 43 44 if (seconds <= 0 || isNaN(seconds)) { 45 seconds = 0; 46 } else { 47 days = Math.floor(seconds / 86400); 48 seconds = seconds % 86400; 49 50 hours = Math.floor(seconds / 3600); 51 seconds = seconds % 3600; 52 53 minutes = Math.floor(seconds / 60); 54 seconds = Math.floor(seconds % 60); 55 } 56 57 var html = ""; 58 59 html += "<div class='countdown-container days'>"; 60 html += "<span class='countdown-value days-bottom'>" + pad(days) + "</span>"; 61 html += "<span class='countdown-heading days-top'>" + count_days + "</span>"; 62 html += "</div>"; 63 64 html += "<div class='countdown-container hours'>"; 65 html += "<span class='countdown-value hours-bottom'>" + pad(hours) + "</span>"; 66 html += "<span class='countdown-heading hours-top'>" + count_hours + "</span>"; 67 html += "</div>"; 68 69 html += "<div class='countdown-container minutes'>"; 70 html += "<span class='countdown-value minutes-bottom'>" + pad(minutes) + "</span>"; 71 html += "<span class='countdown-heading minutes-top'>" + count_minutes + "</span>"; 72 html += "</div>"; 73 74 html += "<div class='countdown-container seconds'>"; 75 html += "<span class='countdown-value seconds-bottom'>" + pad(seconds) + "</span>"; 76 html += "<span class='countdown-heading seconds-top'>" + count_seconds + "</span>"; 77 html += "</div>"; 78 79 this.html(html); 80 }; 81 82 $.fn.countdown = function () { 83 var el = $(this); 84 el.showclock(); 85 86 setInterval(function () { 87 el.showclock(); 88 }, 1000); 89 }; 90 91}(jQuery)); 92 93jQuery(document).ready(function () { 94 if (jQuery(".countdown").length > 0) { 95 jQuery(".countdown").each(function () { 96 jQuery(this).countdown(); 97 }); 98 } 99});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.