1$(function () { 2 if (typeof (__sponsors) === "undefined") return; 3 4 var target = document.querySelector('.sponsors__block'); 5 var take = 6; 6 var current = 0; 7 8 function createSet() { 9 10 var links = []; 11 for (var i = 0; i < take; i++) { 12 var idx = (current * take + i) % __sponsors.length; 13 var obj = __sponsors[idx]; 14 15 var a = document.createElement('a'); 16 a.href = obj.href; 17 var img = new Image(); 18 img.src = obj.src;//'/img/sponsors/' + obj.file + '?width=160&height=70&rmode=pad&bgcolor=FFFFFF'; 19 img.style.display = "none"; 20 a.appendChild(img); 21 links.push(a); 22 } 23 current++; 24 return links; 25 } 26 27 //var links = createSet(); 28 //for (var i = 0; i < links.length; i++) { 29 // var a = target.querySelectorAll('a'); 30 // var newNode = links[i]; 31 // target.replaceChild(newNode, a[i]); 32 // $(newNode).find('img').fadeIn('slow'); 33 //} 34 35 //links.forEach(function (x) { 36 // //_t[0].appendChild(x); 37 //}); 38 39 function setupLinks() { 40 var links = createSet(); 41 var timeouts = []; 42 for (var i = 0; i < links.length; i++) { 43 timeouts.push(i * 100); 44 } 45 timeouts = shuffle(timeouts); 46 for (var i = 0; i < links.length; i++) { 47 window.setTimeout(createfunc(i), timeouts[i]); 48 } 49 50 function createfunc(i) { 51 return function () { 52 var a = target.querySelectorAll('a'); 53 var newNode = links[i]; 54 var oldNode = a[i]; 55 56 $(oldNode).find('img').fadeOut('fast', 57 function () { 58 target.replaceChild(newNode, oldNode); 59 $(newNode).find('img').fadeIn('slow'); 60 }); 61 }; 62 } 63 } 64 65 function shuffle(array) { 66 var currentIndex = array.length, temporaryValue, randomIndex; 67 68 // While there remain elements to shuffle... 69 while (0 !== currentIndex) { 70 71 // Pick a remaining element... 72 randomIndex = Math.floor(Math.random() * currentIndex); 73 currentIndex -= 1; 74 75 // And swap it with the current element. 76 temporaryValue = array[currentIndex]; 77 array[currentIndex] = array[randomIndex]; 78 array[randomIndex] = temporaryValue; 79 } 80 81 return array; 82 } 83 84 setupLinks(); 85 window.setInterval(setupLinks, 5000); 86}); 87 88$(function () { 89 runSponsors('.sponsors__top__items > a', 4); 90 runSponsors('.sponsors__top__items-mobile > a', 2); 91}); 92 93function runSponsors(elems, portionLength) { 94 var _a = $(elems); 95 // split array into portions 96 var portions = []; 97 98 for (var i = 0; i < _a.length; i++) { 99 var portion = []; 100 101 for (var k = 0; k < portionLength; k++) { 102 var el = _a[i]; 103 if (el) { 104 portion.push(el); 105 } 106 i++; 107 } 108 if (portion.length < portionLength) { 109 // this is last portion 110 // add some more to this portion 111 if (portions.length >= 3) { 112 // we should be able to pick more elements from 2nd portion 113 // 0..[1]..2..3<-current 114 var donorPortion = portions[1]; 115 for (var m = 0; portion.length < portionLength; m++) { 116 portion.push(donorPortion[m]); 117 } 118 portions.push(portion); 119 } else { 120 // do not add this portion, we can't fill it to 4 121 } 122 } else { 123 portions.push(portion); 124 } 125 126 } 127 128 var currentPortionIndex = 0; 129 window.setInterval(function () { 130 var newPortionIndex = currentPortionIndex + 1; 131 if (newPortionIndex >= portions.length) { 132 newPortionIndex = 0; 133 } 134 if (newPortionIndex !== currentPortionIndex) { 135 136 var displayPortion = portions[newPortionIndex]; 137 var hidePortion = portions[currentPortionIndex]; 138 139 140 $(hidePortion).fadeOut('slow', function () { $(displayPortion).fadeIn(); }); 141 142 currentPortionIndex = newPortionIndex; 143 } 144 }, 5000); 145}
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.