1/** 2 * Wrapper function to safely use $ 3 */ 4function wpaiWrapper($) { 5 var wpai = { 6 7 /** 8 * Main entry point 9 */ 10 init: function () { 11 12 wpai.findAds(); 13 }, 14 15 16 findAds: function () { 17 var res_array = []; 18 wpai.getCommentsFromEl($('body'),res_array); 19 $(res_array).each( 20 function(x, e) { 21 22 arr = JSON.parse(e.nodeValue.substr(5)); 23 24 var i = 0; 25 inserted = $(arr.ads[i]); 26 inserted.insertAfter($(e)); 27 28 if (arr.ads.length > 1 && arr.rot_dur[i]>0){ 29 wpai.rotate(e, arr,i,inserted); 30 } 31 }); 32 }, 33 34 getCommentsFromEl : function (el, res_array) { 35 var result; 36 $el = $(el).contents(); 37 result = $el.filter(function () { 38 return this.nodeType == 8; 39 }); 40 41 $(result).each(function(x,e){ 42 if (e.nodeValue.substr(0,5).trim()==='WPAI'){ 43 res_array.push(e); 44 } 45 }); 46 47 var result2 = $el.filter(function () { 48 return this.nodeType == 1; //only elements 49 }); 50 51 $(result2).each(function(x,e){ 52 wpai.getCommentsFromEl (e, res_array); 53 }); 54 55 }, 56 57 rotate: function (e, arr, i, inserted){ 58 59 var newi = (i+1) % arr.ads.length; 60 setTimeout(function(){ 61 arr.ads[newi] = arr.ads[newi].replace('#wpai-endc','-->'); 62 newinserted = $(arr.ads[newi]); 63 64 inserted.detach(); 65 newinserted.insertAfter($(e)); 66 67 wpai.rotate(e, arr, newi,newinserted); 68 }, arr.rot_dur[i]*1000); 69 } 70 }; 71 $(document).ready(wpai.init); 72} 73 74wpaiWrapper(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.