1 2/* Text and/or Image Crawler Script v1.53 (c)2009-2012 John Davenport Scheuer 3 as first seen in http://www.dynamicdrive.com/forums/ 4 username: jscheuer1 - This Notice Must Remain for Legal Use 5 updated: 4/2011 for random order option, more (see below) 6 */ 7 8/* Update 4/2011 to v1.5 - Adds optional random property. Set it to true to use. 9 Fixes browser crash from empty crawlers, ad and image blocking software/routines. 10 Fixes behavior in some IE of breaking script if an image is missing. 11 Adds alt attributes to images without them to aid in diagnosis of missing/corrupt 12 images. This may be disabled with the new optional noAddedAlt property set to true. 13 Internal workings enhanced for greater speed of execution, less memory usage. 14 */ 15 16/* Update 11/2011 - Detect and randomize td elements within a single table with a single tr */ 17 18// updated 7/2012 to 1.51 for optional integration with 3rd party initializing scripts - 19// ref: http://www.dynamicdrive.com/forums/showthread.php?p=278161#post278161 20// updated 8/2012 to 1.52 for greater compatibility with IE in Quirks Mode 21 22/* Update 10/2012 to v1.53 - Adds optional persist property to have the crawler remember its 23 position and direction page to page and on page reload. To enable it in the marqueeInit set 24 persist: true, 25 */ 26 27///////////////// No Need to Edit - Configuration is Done in the On Page marqueeInit call(s) ///////////////// 28 29 30function marqueeInit(config){ 31 if(!document.createElement) return; 32 marqueeInit.ar.push(config); 33 marqueeInit.run(config.uniqueid); 34} 35 36(function(){ 37 38 if(!document.createElement) return; 39 40 if(typeof opera === 'undefined'){window.opera = false;} 41 42 marqueeInit.ar = []; 43
44 document.write('<style type="text/css">.marquee{white-space:nowrap;overflow:hidden;visibility:hidden;}' + 45 '#marq_kill_marg_bord{border:none!important;margin:0!important;}<\/style>'); 46 var c = 0, tTRE = [/^\s*$/, /^\s*/, /\s*$/, /[^\/]+$/], 47 req1 = {'position': 'relative', 'overflow': 'hidden'}, defaultconfig = { 48 style: { //default style object for marquee containers without configured style 49 'margin': '0 auto' 50 }, 51 direction: 'left', 52 inc: 2, //default speed - pixel increment for each iteration of a marquee's movement 53 mouse: 'pause' //default mouseover behavior ('pause' 'cursor driven' or false) 54 }, dash, ie = false, oldie = 0, ie5 = false, iever = 0; 55 56 /*@cc_on @*/ 57 /*@if(@_jscript_version >= 5) 58 ie = true; 59 try{document.documentMode = 2000}catch(e){}; 60 iever = Math.min(document.documentMode, navigator.appVersion.replace(/^.*MSIE (\d+\.\d+).*$/, '$1')); 61 if(iever < 6) 62 oldie = 1; 63 if(iever < 5.5){ 64 Array.prototype.push = function(el){this[this.length] = el;}; 65 ie5 = true; 66 dash = /(-(.))/; 67 String.prototype.encamel = function(s, m){ 68 s = this; 69 while((m = dash.exec(s))) 70 s = s.replace(m[1], m[2].toUpperCase()); 71 return s; 72 }; 73 } 74 @end @*/ 75 76 if(!ie5){ 77 dash = /-(.)/g; 78 function toHump(a, b){return b.toUpperCase();}; 79 String.prototype.encamel = function(){return this.replace(dash, toHump);}; 80 } 81 82 if(ie && iever < 8){ 83 marqueeInit.table = []; 84 window.attachEvent('onload', function(){ 85 marqueeInit.OK = true; 86 var i = -1, limit = marqueeInit.table.length; 87 while(++i < limit) 88 marqueeInit.run(marqueeInit.table[i]); 89 }); 90 } 91 92 function intable(el){ 93 while((el = el.parentNode)) 94 if(el.tagName && el.tagName.toLowerCase() === 'table') 95 return true; 96 return false; 97 }; 98 99 marqueeInit.run = function(id){ 100 if(ie && !marqueeInit.OK && iever < 8 && intable(document.getElementById(id))){ 101 marqueeInit.table.push(id); 102 return; 103 } 104 if(!document.getElementById(id)) 105 setTimeout(function(){marqueeInit.run(id);}, 300); 106 else 107 new Marq(c++, document.getElementById(id)); 108 } 109 110 function trimTags(tag){ 111 var r = [], i = 0, e; 112 while((e = tag.firstChild) && e.nodeType === 3 && tTRE[0].test(e.nodeValue)) 113 tag.removeChild(e); 114 while((e = tag.lastChild) && e.nodeType === 3 && tTRE[0].test(e.nodeValue)) 115 tag.removeChild(e); 116 if((e = tag.firstChild) && e.nodeType === 3) 117 e.nodeValue = e.nodeValue.replace(tTRE[1], ''); 118 if((e = tag.lastChild) && e.nodeType === 3) 119 e.nodeValue = e.nodeValue.replace(tTRE[2], ''); 120 while((e = tag.firstChild)) 121 r[i++] = tag.removeChild(e); 122 return r; 123 } 124 125 function randthem(tag){ 126 var els = oldie? tag.all : tag.getElementsByTagName('*'), i = els.length, childels = []; 127 while (--i > -1){ 128 if(els[i].parentNode === tag){ 129 childels.push(els[i]); 130 } 131 } 132 childels.sort(function(){return 0.5 - Math.random();}); 133 i = childels.length; 134 while (--i > -1){ 135 tag.appendChild(childels[i]); 136 } 137 } 138 139 function Marq(c, tag){ 140 var p, u, s, a, ims, ic, i, marqContent, cObj = this; 141 this.mq = marqueeInit.ar[c]; 142 if(this.mq.random){ 143 if(tag.getElementsByTagName && tag.getElementsByTagName('tr').length === 1 && tag.childNodes.length === 1){ 144 randthem(tag.getElementsByTagName('tr')[0]); 145 } else { 146 randthem(tag); 147 } 148 } 149 for (p in defaultconfig) 150 if((this.mq.hasOwnProperty && !this.mq.hasOwnProperty(p)) || (!this.mq.hasOwnProperty && !this.mq[p])) 151 this.mq[p] = defaultconfig[p]; 152 this.mq.direction = this.mq.persist && this.cookie.get(this.mq.uniqueid)? this.cookie.get(this.mq.uniqueid).split(':')[2] : this.mq.direction; 153 this.mq.style.width = !this.mq.style.width || isNaN(parseInt(this.mq.style.width))? '100%' : this.mq.style.width; 154 if(!tag.getElementsByTagName('img')[0]) 155 this.mq.style.height = !this.mq.style.height || isNaN(parseInt(this.mq.style.height))? tag.offsetHeight + 3 + 'px' : this.mq.style.height; 156 else 157 this.mq.style.height = !this.mq.style.height || isNaN(parseInt(this.mq.style.height))? 'auto' : this.mq.style.height; 158 u = this.mq.style.width.split(/\d/); 159 this.cw = this.mq.style.width? [parseInt(this.mq.style.width), u[u.length - 1]] : ['a']; 160 marqContent = trimTags(tag); 161 tag.className = tag.id = ''; 162 tag.removeAttribute('class', 0); 163 tag.removeAttribute('id', 0); 164 if(ie) 165 tag.removeAttribute('className', 0); 166 tag.appendChild(tag.cloneNode(false)); 167 tag.className = ['marquee', c].join(''); 168 tag.style.overflow = 'hidden'; 169 this.c = tag.firstChild; 170 this.c.appendChild(this.c.cloneNode(false)); 171 this.c.style.visibility = 'hidden'; 172 a = [[req1, this.c.style], [this.mq.style, this.c.style]]; 173 for (i = a.length - 1; i > -1; --i) 174 for (p in a[i][0]) 175 if((a[i][0].hasOwnProperty && a[i][0].hasOwnProperty(p)) || (!a[i][0].hasOwnProperty)) 176 a[i][1][p.encamel()] = a[i][0][p]; 177 this.m = this.c.firstChild; 178 if(this.mq.mouse === 'pause'){ 179 this.c.onmouseover = function(){cObj.mq.stopped = true;}; 180 this.c.onmouseout = function(){cObj.mq.stopped = false;}; 181 } 182 this.m.style.position = 'absolute'; 183 this.m.style.left = '-10000000px'; 184 this.m.style.whiteSpace = 'nowrap'; 185 if(ie5) this.c.firstChild.appendChild((this.m = document.createElement('nobr'))); 186 if(!this.mq.noAddedSpace) 187 this.m.appendChild(document.createTextNode('\xa0')); 188 for(i = 0; marqContent[i]; ++i) 189 this.m.appendChild(marqContent[i]); 190 if(ie5) this.m = this.c.firstChild; 191 ims = this.m.getElementsByTagName('img'); 192 if(ims.length){ 193 for(ic = 0, i = 0; i < ims.length; ++i){ 194 ims[i].style.display = 'inline'; 195 if(!ims[i].alt && !this.mq.noAddedAlt){ 196 ims[i].alt = (tTRE[3].exec(ims[i].src)) || ('Image #' + [i + 1]); 197 if(!ims[i].title){ims[i].title = '';} 198 } 199 ims[i].style.display = 'inline'; 200 ims[i].style.verticalAlign = ims[i].style.verticalAlign || 'top'; 201 if(typeof ims[i].complete === 'boolean' && ims[i].complete) 202 ic++; 203 else { 204 ims[i].onload = ims[i].onerror = function(){ 205 if(++ic === ims.length) 206 cObj.setup(c); 207 }; 208 } 209 if(ic === ims.length) 210 this.setup(c); 211 } 212 } 213 else this.setup(c) 214 } 215 216 Marq.prototype.setup = function(c){ 217 if(this.mq.setup) return; 218 this.mq.setup = this; 219 var s, w, cObj = this, exit = 10000; 220 if(this.c.style.height === 'auto') 221 this.c.style.height = this.m.offsetHeight + 4 + 'px'; 222 this.c.appendChild(this.m.cloneNode(true)); 223 this.m = [this.m, this.m.nextSibling]; 224 if(typeof this.mq.initcontent === 'function'){ 225 this.mq.initcontent.apply(this.mq, [this.m]); 226 } 227 if(this.mq.mouse === 'cursor driven'){ 228 this.r = this.mq.neutral || 16; 229 this.sinc = this.mq.inc; 230 this.c.onmousemove = function(e){cObj.mq.stopped = false; cObj.directspeed(e)}; 231 if(this.mq.moveatleast){ 232 this.mq.inc = this.mq.moveatleast; 233 if(this.mq.savedirection){ 234 if(this.mq.savedirection === 'reverse'){ 235 this.c.onmouseout = function(e){ 236 if(cObj.contains(e)) return; 237 cObj.mq.inc = cObj.mq.moveatleast; 238 cObj.mq.direction = cObj.mq.direction === 'right'? 'left' : 'right';}; 239 } else { 240 this.mq.savedirection = this.mq.direction; 241 this.c.onmouseout = function(e){ 242 if(cObj.contains(e)) return; 243 cObj.mq.inc = cObj.mq.moveatleast; 244 cObj.mq.direction = cObj.mq.savedirection;}; 245 } 246 } else 247 this.c.onmouseout = function(e){if(!cObj.contains(e)) cObj.mq.inc = cObj.mq.moveatleast;}; 248 } 249 else 250 this.c.onmouseout = function(e){if(!cObj.contains(e)) cObj.slowdeath();}; 251 } 252 this.w = this.m[0].offsetWidth; 253 this.m[0].style.left = this.mq.persist && this.cookie.get(this.mq.uniqueid)? this.cookie.get(this.mq.uniqueid).split(':')[0] : 0; 254 this.c.id = 'marq_kill_marg_bord'; 255 this.m[0].style.top = this.m[1].style.top = Math.floor((this.c.offsetHeight - this.m[0].offsetHeight) / 2 - oldie) + 'px'; 256 this.c.id = ''; 257 this.c.removeAttribute('id', 0); 258 this.m[1].style.left = this.mq.persist && this.cookie.get(this.mq.uniqueid)? this.cookie.get(this.mq.uniqueid).split(':')[1] : this.w + 'px'; 259 s = this.mq.moveatleast? Math.max(this.mq.moveatleast, this.sinc) : (this.sinc || this.mq.inc); 260 while(this.c.offsetWidth > this.w - s && --exit){ 261 w = isNaN(this.cw[0])? this.w - s : --this.cw[0]; 262 if(w < 1 || this.w < Math.max(1, s)){break;} 263 this.c.style.width = isNaN(this.cw[0])? this.w - s + 'px' : --this.cw[0] + this.cw[1]; 264 } 265 this.c.style.visibility = 'visible'; 266 this.runit(); 267 } 268 269 Marq.prototype.slowdeath = function(){ 270 var cObj = this; 271 if(this.mq.inc){ 272 this.mq.inc -= 1; 273 this.timer = setTimeout(function(){cObj.slowdeath();}, 100); 274 } 275 } 276 277 Marq.prototype.runit = function(){ 278 var cObj = this, d = this.mq.direction === 'right'? 1 : -1; 279 if(this.mq.stopped || this.mq.stopMarquee){ 280 setTimeout(function(){cObj.runit();}, 300); 281 return; 282 } 283 if(this.mq.mouse != 'cursor driven') 284 this.mq.inc = Math.max(1, this.mq.inc); 285 if(d * parseInt(this.m[0].style.left) >= this.w) 286 this.m[0].style.left = parseInt(this.m[1].style.left) - d * this.w + 'px'; 287 if(d * parseInt(this.m[1].style.left) >= this.w) 288 this.m[1].style.left = parseInt(this.m[0].style.left) - d * this.w + 'px'; 289 this.m[0].style.left = parseInt(this.m[0].style.left) + d * this.mq.inc + 'px'; 290 this.m[1].style.left = parseInt(this.m[1].style.left) + d * this.mq.inc + 'px'; 291 if(window.opera && this.mq.persist){ 292 this.cookie.set(this.mq.uniqueid, this.m[0].style.left + ':' + this.m[1].style.left + ':' + this.mq.direction); 293 } 294 setTimeout(function(){cObj.runit();}, 30 + (this.mq.addDelay || 0)); 295 } 296 297 Marq.prototype.cookie = { 298 set: function(n, v, d){ // cook.set takes (name, value, optional_persist_days) - defaults to session if no days specified 299 if(d){var dt = new Date(); 300 dt.setDate(dt.getDate() + d); 301 d = '; expires=' + dt.toGMTString();} 302 document.cookie = n + '=' + escape(v) + (d || '') + '; path=/'; 303 }, 304 get: function(n){ // cook.get takes (name) 305 var c = document.cookie.match('(^|;)\x20*' + n + '=([^;]*)'); 306 return c? unescape(c[2]) : null; 307 }, 308 kill: function(n){ // cook.kill takes (name) 309 cook.set(n, '', -1); 310 }, 311 killall: function(){ // cook.killall takes no parameters 312 var cookies = document.cookie.split(';
312'), i = cookies.length - 1; 313 for (i; i > -1; --i){ 314 cook.kill(cookies[i].split('=')[0]); 315 } 316 } 317 }; 318 319 Marq.prototype.directspeed = function(e){ 320 e = e || window.event; 321 if(this.timer) clearTimeout(this.timer); 322 var c = this.c, w = c.offsetWidth, l = c.offsetLeft, mp = (typeof e.pageX === 'number'? 323 e.pageX : e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft) - l, 324 lb = (w - this.r) / 2, rb = (w + this.r) / 2; 325 while((c = c.offsetParent)) mp -= c.offsetLeft; 326 this.mq.direction = mp > rb? 'left' : 'right'; 327 this.mq.inc = Math.round((mp > rb? (mp - rb) : mp < lb? (lb - mp) : 0) / lb * this.sinc); 328 } 329 330 Marq.prototype.contains = function(e){ 331 if(e && e.relatedTarget){var c = e.relatedTarget; if(c === this.c) return true; 332 while ((c = c.parentNode)) if(c === this.c) return true;} 333 return false; 334 } 335 336 function resize(){ 337 for(var s, w, m, i = 0; i < marqueeInit.ar.length; ++i){ 338 if(marqueeInit.ar[i] && marqueeInit.ar[i].setup){ 339 m = marqueeInit.ar[i].setup; 340 s = m.mq.moveatleast? Math.max(m.mq.moveatleast, m.sinc) : (m.sinc || m.mq.inc); 341 m.c.style.width = m.mq.style.width; 342 m.cw[0] = m.cw.length > 1? parseInt(m.mq.style.width) : 'a'; 343 while(m.c.offsetWidth > m.w - s){ 344 w = isNaN(m.cw[0])? m.w - s : --m.cw[0]; 345 if(w < 1){break;} 346 m.c.style.width = isNaN(m.cw[0])? m.w - s + 'px' : --m.cw[0] + m.cw[1]; 347 } 348 } 349 } 350 } 351 352 function unload(){ 353 for(var m, i = 0; i < marqueeInit.ar.length; ++i){ 354 if(marqueeInit.ar[i] && marqueeInit.ar[i].persist && marqueeInit.ar[i].setup){ 355 m = marqueeInit.ar[i].setup; 356 m.cookie.set(m.mq.uniqueid, m.m[0].style.left + ':' + m.m[1].style.left + ':' + m.mq.direction); 357 } 358 } 359 } 360 361 if (window.addEventListener){ 362 window.addEventListener('resize', resize, false); 363 window.addEventListener('unload', unload, false); 364 } 365 else if (window.attachEvent){ 366 window.attachEvent('onresize', resize); 367 window.attachEvent('onunload', unload); 368 } 369 370})();
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.