1(function($){ 2 const specTimer = { 3 init:function(options, el) { 4 var base = this; 5 6 base.options = $.extend({}, $.fn.uniTimer.options, options); 7 base.days = 24*60*60, base.hours = 60*60, base.minutes = 60; 8 9 var date_arr = base.options.date.split('-'), year = parseFloat(date_arr[0]), month = parseFloat(date_arr[1])-1, day = parseFloat(date_arr[2]); 10 11 base.$date = (new Date(year, month, day)).getTime(); 12 base.$elem = $(el); 13 14 if(base.$date > (new Date()).getTime()) { 15 html = '<div class="uni-timer">'; 16 17 for(i in base.options.texts){ 18 html += '<div class="uni-timer__group g-'+i+'">'; 19 html += '<div class="uni-timer__digit"></div>'; 20 html += '<div class="uni-timer__text">'+base.options.texts[i]+'</div>'; 21 html += '</div>'; 22 } 23 24 html += '</div>'; 25 26 base.$elem.append(html); 27 base.digits = base.$elem.find('.uni-timer__digit'); 28 base.count(); 29 } 30 }, 31 count:function() { 32 var base = this, left, d, h, m, s; 33 34 left = Math.floor((base.$date - (new Date()).getTime())/1000); 35 36 left = left > 0 ? left : 0; 37 38 d = Math.floor(left / base.days); 39 left -= d*base.days; 40 h = Math.floor(left / base.hours); 41 left -= h*base.hours; 42 m = Math.floor(left / base.minutes); 43 left -= m*base.minutes; 44 s = left; 45 46 base.switchDigit([d, h, m, s]); 47 48 setTimeout(() => { 49 base.count(); 50 }, 1000); 51 }, 52 switchDigit:function(digits) { 53 var base = this; 54 55 for(i in digits) { 56 base.digits.eq(i).text(digits[i]) 57 } 58 }, 59 } 60 61 $.fn.uniTimer = function(options) { 62 return this.each(function() { 63 if ($(this).data("uni-timer-init") === true) { 64 return false; 65 } 66 67 $(this).data("uni-timer-init", true); 68 69 var timer = Object.create(specTimer); 70 timer.init(options, this); 71 }); 72 }; 73 74 $.fn.uniTimer.options = { 75 date :'0000-00-00', 76 texts :['Ðней','ЧаÑов','ÐинÑÑ','СекÑнд'] 77 }; 78})(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.