1(function ($) { 2 "use strict"; 3 4 $.fn.extend({ 5 ctecountdown100: function(options) { 6 var defaults = { 7 link:"#", 8 timeZone: "", 9 endtimeYear: 0, 10 endtimeMonth: 0, 11 endtimeDate: 0, 12 endtimeHours: 0, 13 endtimeMinutes: 0, 14 endtimeSeconds: 0, 15 } 16 17 var options = $.extend(defaults, options); 18 19 return this.each(function() { 20 var obj = $(this); 21 var timeNow = new Date(); 22 var link = options.link; 23 var tZ = options.timeZone; /*console.log(tZ);*/ 24 var endYear = options.endtimeYear; 25 var endMonth = options.endtimeMonth; 26 var endDate = options.endtimeDate; 27 var endHours = options.endtimeHours; 28 var endMinutes = options.endtimeMinutes; 29 var endSeconds = options.endtimeSeconds; 30 /* console.log( options );*/ 31 32 if(tZ == "") { 33 var deadline = new Date( 34 endYear, 35 endMonth - 1, 36 endDate, 37 endHours, 38 endMinutes, 39 endSeconds 40 ); 41 } 42 else { 43 var deadline = moment.tz([endYear, endMonth - 1, endDate, endHours, endMinutes, endSeconds], tZ).format(); 44 } 45 46 // if(Date.parse(deadline) < Date.parse(timeNow)) { 47 // var deadline = new Date(Date.parse(new Date()) + endDate * 24 * 60 * 60 * 1000 + endHours * 60 * 60 * 1000); 48 // } 49 50 51 initializeClock(deadline); 52 53 function getTimeRemaining(endtime) { 54 55 var t = Date.parse(endtime) - Date.parse(new Date()); 56 var seconds = Math.floor((t / 1000) % 60); 57 var minutes = Math.floor((t / 1000 / 60) % 60); 58 var hours = Math.floor((t / (1000 * 60 * 60)) % 24); 59 var days = Math.floor(t / (1000 * 60 * 60 * 24)); 60 61 return { 62 'total': t, 63 'days': days, 64 'hours': hours, 65 'minutes': minutes, 66 'seconds': seconds 67 }; 68 } 69 70 function initializeClock(endtime) { 71 var daysSpan = $(obj).find('.days'); 72 var hoursSpan = $(obj).find('.hours'); 73 var minutesSpan = $(obj).find('.minutes'); 74 var secondsSpan = $(obj).find('.seconds'); 75 76 function updateClock() { 77 var t = getTimeRemaining(endtime); 78 79 80 daysSpan.html(t.days); 81 hoursSpan.html(('0' + t.hours).slice(-2)); 82 minutesSpan.html(('0' + t.minutes).slice(-2)); 83 secondsSpan.html(('0' + t.seconds).slice(-2)) 84 85 if (t.total <= 0) { 86 clearInterval(timeinterval); 87 alert("TimeOut"); 88 window.location.href = link; 89 } 90 } 91 92 updateClock(); 93 var timeinterval = setInterval(updateClock, 1000); 94 } 95 96 97 98 99 }); 100 } 101 }); 102 103 104 105})(jQuery); 106 107 108 109(function ($) { 110 "use strict"; 111 $(document).ready(function () { 112 $.each( $('.cd100') , function() { 113 var counter = this ; 114 var countdown = $(counter).data('countdown') ; 115 116 $(this).ctecountdown100( { 117 118 //Set Endtime here 119 //Endtime must be > current time 120 link:countdown.link, 121 timeZone: countdown.time_zone, 122 endtimeYear: countdown.endYear, 123 endtimeMonth: countdown.endMonth, 124 endtimeDate: countdown.endDate, 125 endtimeHours: countdown.endHours, 126 endtimeMinutes: countdown.endMinutes, 127 endtimeSeconds: countdown.endSeconds, 128 // ex: timeZone: "America/New_York" 129 //go to " http://momentjs.com/timezone/ " to get timezone 130 }); 131 }); 132 133 }); 134 135 136 137})(jQuery);
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.