1$.countDown = { 2 init: function(){ 3 var self = this; 4 this.num = [ 'zero','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']; 5 this.$elem = [ 6 [ $('#day1'), $('#day2'), $('#day3') ], 7 [ $('#hour1'), $('#hour2') ], 8 [ $('#minute1'), $('#minute2') ], 9 [ $('#second1'), $('#second2') ] 10 ]; 11 this.limit = new Date( 2014, 2, 1, 11, 0, 0 ); 12 this.get(); 13 this.timer(); 14 }, 15 count: function(){ 16 var self = this, 17 day = new Array, 18 sec = this.today.getTime() + 1000, 19 _today = this.today, 20 diff; 21 22 _today.setTime( sec ); 23 diff = this.limit - _today; 24 25 day[0] = this.addZero(Math.floor((diff)/(24*60*60*1000)), true); 26 day[1] = this.addZero(Math.floor(((diff)%(24*60*60*1000))/(60*60*1000)), false); 27 day[2] = this.addZero(Math.floor(((diff)%(24*60*60*1000))/(60*1000))%60, false); 28 day[3] = this.addZero(Math.floor(((diff)%(24*60*60*1000))/1000)%60%60, false); 29 30 this.set( day ); 31 }, 32 get: function(){ 33 var self = this, 34 y, m, d, h, i, s, 35 url = 'time.php?' + new Date().getTime(); 36 $.getJSON(url , function(data){ 37 y = data.year; 38 m = data.mon - 1; 39 d = data.mday; 40 h = data.hours; 41 i = data.minutes; 42 s = data.seconds; 43 self.today = new Date(y, m, d, h, i, s); 44 }); 45 }, 46 set: function( day ){ 47 var self = this; 48 49 var toNumArray = function( num ){ 50 var param = num.toString(); 51 return param.split(''); 52 }; 53 54 for( var i=0; i<4; i++ ){ 55 day[i] = toNumArray( day[i] ); 56 var len = day[i].length; 57 for( var j=0; j<len; j++ ){ 58 var x = Number(day[i][j]); 59 self.num[x] 60 self.$elem[i][j].attr('class', self.num[x] ); 61 }; 62 }; 63 64 //this.timer(); 65 }, 66 addZero: function( num, isDay ){ 67 if( isDay ){ 68 if( num < 100 && num >= 10 ){ 69 num = '0' + num; 70 }else if( num < 10 ){ 71 num = '00' + num; 72 }; 73 }else{ 74 if( num < 10 ){ 75 num = '0' + num; 76 }; 77 }; 78 return num; 79 }, 80 timer: function(){ 81 var self = this; 82 setInterval(function(){ 83 self.count(); 84 }, 1000); 85 } 86}; 87 88 89$.fn.slideFade = function(){ 90 this.each(function(){ 91 new $.SlideFade( this ); 92 }); 93}; 94 95$.SlideFade = function( _this ){ 96 this.$wrap = $(_this); 97 this.$slide = this.$wrap.children('.slideContent'); 98 this.$unit = this.$slide.children('.slideImage'); 99 this.$prev = this.$wrap.find('.slideNavPrev'); 100 this.$next = this.$wrap.find('.slideNavNext'); 101 this.len = this.$unit.length; 102 if( this.len == 1 ){ 103 this.$next.hide(0); 104 this.$prev.hide(0); 105 return false; 106 }; 107 this.pos = 0; 108 this.init(); 109}; 110 111$.SlideFade.prototype = { 112 init: function(){ 113 var self = this;
114 // $container = $('<div class="slideNavContainer" />'); 115 // $nav = $('<div class="slideNav" />'); 116 117 this.isFading = false; 118 119 // for( var i=0; i<this.len; i++ ){ 120 // var $count = $('<div class="sideNavCount" />'), 121 // $a = $('<a href="#" data-count="'+ i +'">' + i + '</a>'); 122 // if( i == 0 ){ 123 // $a.addClass('active'); 124 // }; 125 // $count.append( $a ); 126 // $count.appendTo( $nav ); 127 // }; 128 // $nav.appendTo( $container ) 129 // this.$slide.append( $container ); 130 131 // this.$a = this.$wrap.find('.sideNavCount').children('a'); 132 133 this.set(1); 134 this.start(); 135 this.action(); 136 }, 137 start: function(){ 138 var self = this; 139 this.timer = setTimeout(function(){ 140 var _next = self.pos + 1; 141 if( _next == self.len ){ 142 _next = 0; 143 }; 144 self.isFading = true; 145 self.fade( _next ); 146 }, 8000); 147 }, 148 fade: function( _next ){ 149 var self = this; 150 this.$unit.filter(function(i){ 151 if( i == _next ){ 152 return $(this); 153 }; 154 }).css('z-index', self.len - 1); 155 156 // this.$a.each(function(i){ 157 // if( i == _next ){ 158 // $(this).addClass('active'); 159 // }else{ 160 // $(this).removeClass('active'); 161 // }; 162 // }); 163 164 this.$unit.filter(function(i){ 165 if( i == self.pos ){ 166 return $(this); 167 }; 168 }).fadeOut(1000, function(){ 169 self.pos = _next; 170 var next = self.pos + 1; 171 if( next == self.len ){ 172 next = 0; 173 }; 174 self.set( next ); 175 self.start(); 176 }); 177 }, 178 set: function( _next ){ 179 var self = this, 180 z = this.len; 181 this.$unit.each(function(i){ 182 if( i == self.pos ){ 183 $(this).css({ 184 'position': 'absolute', 185 'top': 0, 186 'left': 0, 187 'z-index': z, 188 'display': 'block' 189 }); 190 }else if( i == _next ){ 191 $(this).css({ 192 'position': 'relative', 193 'top': 0, 194 'left': 0, 195 'z-index': z - 1, 196 'display': 'block' 197 }); 198 }else{ 199 $(this).css({ 200 'position': 'absolute', 201 'top': 0, 202 'left': 0, 203 'z-index': 0, 204 'display': 'block' 205 }); 206 }; 207 }); 208 self.isFading = false; 209 }, 210 action: function(){ 211 var self = this; 212 // this.$a.on('click', function(e){ 213 // e.preventDefault(); 214 // if( $(this).is('.active') || self.isFading ) return false; 215 // self.isFading = true; 216 // var _num = parseInt( $(this).attr('data-count') ); 217 // clearTimeout( self.timer ); 218 // self.fade( _num ); 219 // }); 220 221 this.$prev.on('click', function(e){ 222 e.preventDefault(); 223 if( self.isFading ) return false; 224 self.isFading = true; 225 _num = self.pos - 1; 226 if( _num == -1 ){ 227 _num = self.len - 1; 228 }; 229 clearTimeout( self.timer ); 230 self.fade( _num ); 231 }); 232 233 this.$next.on('click', function(e){ 234 e.preventDefault(); 235 if( self.isFading ) return false; 236 self.isFading = true; 237 _num = self.pos + 1; 238 if( _num == self.len ){ 239 _num = 0; 240 }; 241 clearTimeout( self.timer ); 242 self.fade( _num ); 243 }); 244 } 245}
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.