1$(document).ready(function() 2{ 3 Sponsors.start(); 4}); 5 6 7 8var Sponsors = 9{ 10 currentIndex: 4, // We'll start at image (5) as the first (1-4 11 sponsorTemplate: null, 12 allSponsors: null, 13 sponsorContainer: null, 14 start: function() 15 { 16 var sponsorsWrapper = $('#sponsor-wrapper'); 17 Sponsors.sponsorContainer = $('#sponsor-container', sponsorsWrapper); 18 Sponsors.sponsorTemplate = $('.sponsor-item-template', sponsorsWrapper); 19 Sponsors.allSponsors = JSON.parse(Sponsors.sponsorContainer.attr('data-all-sponsors') || "[]"); 20 if (Sponsors.allSponsors.length > 4) { 21 // set the minimum height of the container to the current height 22 Sponsors.sponsorContainer.css("min-height", Sponsors.sponsorContainer.height() + "px"); 23 24 // If the length of the sponsors does not exceed 4, there is no additional logic to execute 25 window.setInterval(Sponsors.run, 4000); 26 } 27 }, 28 run: function() { 29 var start = Sponsors.currentIndex; 30 var end = Math.min(start + 4, Sponsors.allSponsors.length); 31 if (start == 0 && Sponsors.allSponsors.length < 8) { 32 // If there are between 5-7 items, leave the remainder displayed as is. 33 end = Sponsors.allSponsors.length % 4; 34 } 35 var nextSponsors = Sponsors.allSponsors.slice(start, end); 36 var newSponsorCount = nextSponsors.length; 37 Sponsors.currentIndex = Sponsors.currentIndex + 4; 38 if (Sponsors.currentIndex >= Sponsors.allSponsors.length) { 39 // start from the beginning on next run 40 Sponsors.currentIndex = 0; 41 } 42 var oldSponsors = $(".sponsor-single:nth-child(-n+" + newSponsorCount + ")", Sponsors.sponsorContainer); 43 var lastRun = oldSponsors.length; 44 45 oldSponsors.fadeOut( 46 500, function() { 47 if (--lastRun == 0) { 48 oldSponsors.remove(); 49 for (var [k, v] of Object.entries(nextSponsors.reverse())) { 50 var newElement = Sponsors.sponsorTemplate.clone(); 51 var newLink = $(".brought-by-link", newElement); 52 var newImage = $(".brought-by-image", newElement); 53 newImage.attr("src", v.image_url); 54 // Not all sponsors have a url, so we need to check and remove the link from the template if not 55 if (v.url) { 56 newLink.attr("href", v.url); 57 } else { 58 newLink.replaceWith(newImage); 59 } 60 $(".row", Sponsors.sponsorContainer).prepend(newElement); 61 newElement.fadeIn(500); 62 } 63 } 64 65 }); 66 }, 67};
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.