1/** 2 * Plugin kkcountdown counts down to specific dates in the future. 3 * 4 * @example 5 * $(".come-class").kkcountdown(); 6 * 7 * @type jQuery 8 * 9 * @name kkcountdown 10 * @author Krzysztof Furtak http://krzysztof-furtak.pl/ 11 * @version 1.3.8 12 * 13 * Documentation: http://krzysztof-furtak.pl/kk-countdown-jquery-plugin/ 14 * 15 */ 16 17(function($){ 18 $.fn.kkcountdown = function(options) { 19 var defaults = { 20 dayText : 'day ', 21 days2Text : 'days ', 22 daysText : 'days ', 23 hourText : ':', 24 hours2Text : 'hours ', 25 hoursText : ':', 26 minutesText : ':', 27 secondsText : '', 28 textAfterCount : '---', 29 oneDayClass : false, 30 displayDays : true, 31 displayZeroDays : true, 32 addClass : false, 33 callback : false, 34 warnSeconds : 60, 35 warnClass : false, 36 rusNumbers : false 37 }; 38 39 var options = $.extend(defaults, options); 40 41 // rather than continue to read the timestamp/seconds from the dom element, store it within the plugin 42 var countdowns = new Array(); 43 44 this.each(function(){ 45 var _this = $(this); 46 47 var box = $(document.createElement('span')).addClass('kkcountdown-box'); 48 var boxDni = $(document.createElement('span')).addClass('kkc-dni'); 49 var boxGodz = $(document.createElement('span')).addClass('kkc-godz'); 50 var boxMin = $(document.createElement('span')).addClass('kkc-min'); 51 var boxSec = $(document.createElement('span')).addClass('kkc-sec'); 52 var boxDniText = $(document.createElement('span')).addClass('kkc-dni-text'); 53 var boxGodzText = $(document.createElement('span')).addClass('kkc-godz-text'); 54 var boxMinText = $(document.createElement('span')).addClass('kkc-min-text'); 55 var boxSecText = $(document.createElement('span')).addClass('kkc-sec-text'); 56 57 if(options.addClass != false){ 58 box.addClass(options.addClass); 59 } 60 61 boxGodzText.html(options.hoursText); 62 boxMinText.html(options.minutesText); 63 boxSecText.html(options.secondsText); 64 65 box.append(boxDni).append(boxDniText).append(boxGodz).append(boxGodzText).append(boxMin).append(boxMinText).append(boxSec).append(boxSecText); 66 _this.append(box); 67 68 kkCountdownInit(_this); 69 70 }); 71 72 function kkCountdownInit(_this){ 73 /* 74 * look first for the number of seconds and not a time attribute on the object 75 * - time relies on the browser's time being set in sync with the server 76 * - number of seconds can be confidently set based on the server time 77 */ 78 var count = 0; 79 if (_this.id === undefined) { 80 _this.id = 'kk_'+ Math.random( new Date().getTime() ); 81 } 82 if (_this.id in countdowns) count = countdowns[_this.id]; 83 else count = _this.attr('data-seconds'); 84 85 if (count === undefined) { 86 var now = new Date(); 87 now = Math.floor(now.getTime() / 1000); 88 var event = _this.attr('data-time'); 89 if (event === undefined) event = _this.attr('time'); // backward-compatibility 90 count = event - now; 91 } 92 countdowns[_this.id] = count-1; 93 94 if (options.warnClass && count < options.warnSeconds) { 95 _this.addClass(options.warnClass) 96 } 97 if(count < 0){ 98 _this.html(options.textAfterCount); 99 if(options.callback){ 100 options.callback(_this); 101 } 102 }else if(count <= 24*60*60){ 103 setTimeout(function(){ 104 kkCountDown(true, _this, count); 105 kkCountdownInit(_this); 106 }, 1000); 107 }else{ 108 setTimeout(function(){ 109 kkCountDown(false, _this, count); 110 kkCountdownInit(_this); 111 }, 1000); 112 } 113 } 114 115 function kkCountDown(oneDay, obj, count){ 116 var sekundy = naprawaCzasu(count % 60);
117 count = Math.floor(count/60); 118 var minuty = naprawaCzasu(count % 60); 119 count = Math.floor(count/60); 120 var godziny = naprawaCzasu(count % 24); 121 count = Math.floor(count/24); 122 var dni = count; 123 124 if(oneDay && options.oneDayClass != false){ 125 obj.addClass(options.oneDayClass); 126 } 127 128 if (dni == 0 && !options.displayZeroDays) { 129 130 } else { 131 obj.find('.kkc-dni').html(dni); 132 obj.find('.kkc-dni-text').html(formatNumberedText(dni, 'day')); 133 } 134 135 obj.find('.kkc-godz').html(godziny); 136 obj.find('.kkc-godz-text').html(formatNumberedText(godziny, 'hour')); 137 138 obj.find('.kkc-min').html(minuty); 139 obj.find('.kkc-sec').html(sekundy); 140 } 141 142 /** 143 * @var int number 144 * @var string optionText - {daysText: day, dayText: day, hoursText: hour, etc} 145 */ 146 function formatNumberedText(number, optionText) { 147 var daysText = options[optionText+'sText']; 148 149 if (options.rusNumbers) { 150 if (number >= 5 && number < 20) { 151 daysText = options[optionText+'sText']; 152 } else { 153 var lastDigit = (""+number).replace(/^\d+(\d)$/, '$1') * 1; 154 if (lastDigit == 1) { 155 daysText = options[optionText+'Text']; 156 } else { 157 if (lastDigit >= 2 && lastDigit <= 4) { 158 daysText = options[optionText+'s2Text']; 159 } else { 160 daysText = options[optionText+'sText']; 161 } 162 } 163 } 164 } else { 165 if (1 == number) { 166 daysText = options[optionText+'Text']; 167 } 168 } 169 return daysText; 170 } 171 172 function naprawaCzasu(obj){ 173 s = ''; 174 if(obj < 10){ 175 obj = '0' + obj; 176 } 177 return obj; 178 } 179 } 180})(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.