1/** 2 * @preserve jQuery flipcountdown plugin v3.0.5 3 * @homepage http://xdsoft.net/jqplugins/flipcountdown/ 4 * (c) 2013, Chupurnov Valeriy. 5 */ 6(function($){ 7jQuery.fn.flipCountDown = jQuery.fn.flipcountdown = function( _options ){ 8 var default_options = { 9 showHour :true, 10 showMinute :true, 11 showSecond :true, 12 am :false, 13 14 tzoneOffset :0, 15 speedFlip :60, 16 period :1000, 17 tick :function(){ 18 return new Date(); 19 }, 20 autoUpdate :true, 21 size :'md', 22 23 beforeDateTime:false, 24 25 prettyPrint :function( chars ){ 26 return (chars instanceof Array)?chars.join(' '):chars; 27 } 28 }, 29 30 digitsCount = 66, 31 32 sizes = { 33 lg:77, 34 md:52, 35 sm:35, 36 xs:24 37 }, 38 39 createFlipCountDown = function( $box ){ 40 var $flipcountdown = $('<div class="xdsoft_flipcountdown"></div>'), 41 $clearex = $('<div class="xdsoft_clearex"></div>'), 42 43 options = $.extend({},default_options), 44 45 timer = 0, 46 47 _animateRange = function( box,a,b ){ 48 if( !isNaN(a) ){ 49 _animateOne( box,a,((a>b && !(a==9&&b==0) )||(a==0&&b==9))?-1:1,!((a==9&&b==0)||(a==0&&b==9))?Math.abs(a-b):1 ); 50 }else{ 51 box.css('background-position','0px -'+((b+1)*6*sizes[options.size]+1)+'px' ); 52 } 53 }, 54 55 _animateOne = function( box,a,arrow,range ){ 56 if( range<1 ) 57 return; 58 59 _setMargin(box,-((a+1)*6*sizes[options.size]+1),1,arrow,function(){ 60 _animateOne(box,a+arrow,arrow,range-1); 61 },range); 62 }, 63 64 _setMargin = function( box, marginTop, rec, arrow,callback,range){ 65 if( marginTop<=-sizes[options.size]*digitsCount ) 66 marginTop = -(6*sizes[options.size]+1); 67 box.css('background-position','0px '+marginTop+'px' ); 68 if( rec<=6 ){ 69 setTimeout(function(){ 70 _setMargin(box, marginTop-arrow*sizes[options.size], ++rec, arrow, callback,range); 71 },parseInt(options.speedFlip/range)); 72 }else 73 callback(); 74 }, 75 76 blocks = [], 77 78 _typeCompare = function ( a,b ){ 79 return a&&b&&( 80 (a==b)|| 81 (/^[0-9]+$/.test(a+''+b))|| 82 (/^[:.\s]+$/.test(a+''+b)) 83 ); 84 }, 85 86 _generate = function( chars ){ 87 if( !(chars instanceof Array) || !chars.length ) 88 return false; 89 for( var i = 0, n = chars.length;i<n;i++ ){ 90 if( !blocks[i] ){ 91 blocks[i] = $('<div class="xdsoft_digit"></div>'); 92 $clearex.before(blocks[i]); 93 } 94 if( blocks[i].data('value')!=chars[i] ){ 95 if( !_typeCompare(blocks[i].data('value'),chars[i]) ){ 96 blocks[i] 97 .removeClass('xdsoft_separator') 98 .removeClass('xdsoft_dot'); 99 switch( chars[i] ){ 100 case ':':blocks[i].addClass('xdsoft_separator');break; 101 case '.':blocks[i].addClass('xdsoft_dot');break; 102 case ' ':blocks[i].addClass('xdsoft_space');break; 103 } 104 } 105 if( !isNaN(chars[i]) ){ 106 var old = parseInt(blocks[i].data('value')), 107 ii = parseInt(blocks[i].data('i')), 108 crnt = parseInt(chars[i]); 109 _animateRange(blocks[i],old,crnt); 110 } 111 blocks[i].data('value',chars[i]); 112 blocks[i].data('i',i); 113 } 114 } 115 if( blocks.length>chars.length ){ 116 for(;i<blocks.length;i++ ){ 117 blocks[i][0].parentNode.removeChild(blocks[i][0]); 118 delete blocks[i]; 119 } 120 blocks.splice(chars.length); 121 } 122 123 }, 124 125 counter = 0, 126 127 _calcMoment = function(){ 128 var value = '1',chars = []; 129 if(options.tick) 130 value = options.prettyPrint.call($box,(options.tick instanceof Function)?options.tick.call($box,counter):options.tick); 131 132 if( typeof value!=='undefined' ){ 133 switch( value.constructor ){ 134 case Date: 135 var h = (value.getHours()+options.tzoneOffset)%(options.am?12:24); 136 137 if( options.showHour ){ 138 chars.push(parseInt(h/10)); 139 chars.push(h%10); 140 } 141 142 if( options.showHour && (options.showMinute || options.showSecond) ) 143 chars.push(':'); 144 145 if( options.showMinute ){ 146 chars.push(parseInt(value.getMinutes()/10)); 147 chars.push(value.getMinutes() % 10); 148 } 149 150 if( options.showMinute && options.showSecond ) 151 chars.push(':'); 152 153 if( options.showSecond ){ 154 chars.push(parseInt(value.getSeconds()/10)); 155 chars.push(value.getSeconds() % 10); 156 } 157 break; 158 case String: 159 var parts = value.replace(/[^0-9\:\.\s]/g,'').split(' '); 160 161 for (var i = 0; i < parts.length; i++) { 162 if ((parts[i].length > 2) && (parts[i][0] === '0')) { 163 parts[i] = parts[i].substring(1); 164 } 165 } 166 167 if (options.showSecond === false){ 168 parts.pop(); 169 } 170 171 value = parts.join(':'); 172 value = value.replace(/\:/,' '); 173 chars = value.replace(/[^0-9\:\.\s]/g,'').split(''); 174 break; 175 case Number: 176 chars = value.toString().split(''); 177 break; 178 } 179 _generate(chars); 180 } 181 }; 182 183 184 185 $flipcountdown 186 .append($clearex) 187 .on('xdinit.xdsoft',function(){ 188 clearInterval(timer); 189 if( options.autoUpdate ) 190 timer = setInterval( _calcMoment,options.period ); 191 _calcMoment(); 192 }); 193 194 $box.data('setOptions',function( _options ){ 195 options = $.extend(true,{},options,_options); 196 if( !sizes[options.size] ) 197 options.size = defaulOptions.size; 198 199 if( options.beforeDateTime && !_options.tick ){ 200 if( typeof(options.beforeDateTime) == 'string' ) 201 options.beforeDateTime = Math.round((new Date(options.beforeDateTime)).getTime()/1000); 202 else{ 203 if ( Object.prototype.toString.call(options.beforeDateTime) !== "[object Date]" ) 204 options.beforeDateTime = Math.round((new Date()).getTime()/1000)+365*24*60; 205 } 206 var nol = function(h){ 207 return h>9?h:'0'+h; 208 } 209 210 options.tick = function(){ 211 var range = options.beforeDateTime-Math.round((new Date()).getTime()/1000), 212 secday = 86400, sechour = 3600, 213 days = parseInt(range/secday), 214 hours = parseInt((range%secday)/sechour), 215 min = parseInt(((range%secday)%sechour)/60), 216 sec = ((range%secday)%sechour)%60; 217 return [nol(days),nol(hours),nol(min),nol(sec)]; 218 } 219 } 220 221 $flipcountdown 222 .addClass('xdsoft_size_'+options.size) 223 .trigger('xdinit.xdsoft'); 224 }); 225 $box.append($flipcountdown); 226 }; 227 return this.each(function(){ 228 var $box = $(this); 229 if( !$box.data('setOptions') ){ 230 $box.addClass('xdsoft') 231 createFlipCountDown($box); 232 } 233 $box.data('setOptions')&& 234 $.isFunction($box.data('setOptions'))&& 235 $box.data('setOptions')(_options); 236 }); 237} 238})(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.