fcSMedias = ""; var tileStep = 0; function fcIsVisible(element) { if (typeof jQuery === "function" && element instanceof jQuery) { element = element[0]; } var rect = element.getBoundingClientRect(); return ( rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth) ); } function fcTriggerEffects() { var pulses = []; var twirls = []; var flashes = []; $(".effect-pulse").each(function () { if (parseInt($(".effect-pulse").attr("effect-delay")) > 0) { if ((timer / parseInt($(".effect-pulse").attr("effect-delay"))) % 1 === 0) { if (fcIsVisible($(this))) { pulses.push($(this)); } } } }); $(".effect-twirl").each(function () { if (parseInt($(".effect-twirl").attr("effect-delay")) > 0) { if ((timer / parseInt($(".effect-twirl").attr("effect-delay"))) % 1 === 0) { if (fcIsVisible($(this))) { twirls.push($(this)); } } } }); $(".effect-flash").each(function () { if (parseInt($(".effect-flash").attr("effect-delay")) > 0) { if ((timer / parseInt($(".effect-flash").attr("effect-delay"))) % 1 === 0) { if (fcIsVisible($(this))) { flashes.push($(this)); } } } }); if (pulses.length > 0) { var random = pulses[Math.floor(Math.random() * pulses.length)]; fcRunEffect(random, "pulse"); } if (twirls.length > 0) { var random = twirls[Math.floor(Math.random() * twirls.length)]; fcRunEffect(random, "twirl"); } if (flashes.length > 0) { var random = flashes[Math.floor(Math.random() * flashes.length)]; fcRunEffect(random, "flash"); } timer++; } function fcRunEffect(element, type) { if (type == "flash") { $(element).find(".fcChunkWhiter").show().fadeOut(750); } else if (type == "twirl") { $(element).addClass("fcChunkTwirl"); setTimeout(function() {$(element).removeClass("fcChunkTwirl");}, 750); } else if (type == "pulse") { $(element).addClass("fcChunkPulse"); setTimeout(function() {$(element).removeClass("fcChunkPulse");}, 750); } } function fcRemoveDuplicates(id) { var elements = []; $("#"+id+" .fcChunk").each(function () { if (elements.indexOf($(this).find(".fcChunkSMID").val()) > -1 && $(this).find(".fcChunkSMID").val() != "" && $(this).find(".fcChunkSMID").val() != undefined) { $(this).hide(); } else { elements.push($(this).find(".fcChunkSMID").val()); } }); } function fcLoadTiles(id, search, hashtag) { if (!loadingTiles) { loadingTiles = true; var fcSearch; var fcHashtag; if (search != undefined) {fcSearch = search;} else {fcSearch = "";} if (hashtag != undefined) {fcSearch = hashtag;} else {fcHashtag = "";} $.ajax({ type:"POST", data: { fcExternalAction : "fcGetTiles", fcStep : tileStep, fcTiles : $("#"+id+" .fcItem, #"+id+" .fcChunk").length, fcFeeds : "0", fcUsers : "0", fcSMedias : fcSMedias, fcRefererID : "", fcThemeID : "0", fcUserGroupID : "0", fcPageID : "0", fcSearch : fcSearch, fcHashtag : fcHashtag, fcKeyword : "", fcCategory : "", fcYear : "", fcMonth : "", fcClientSelected : "45", fcTileTypes : "all", fcBanners : "true", fcForceLimit : "false", fcModule : "page" }, url:"https://www.feedcowboy.com/fc.output.php", success: function(data) { loadingTiles = false; $("#"+id).append(data); fcRemoveDuplicates(id); $(".fcTriggerReposition").load(function() { fcRepositionTiles(id, columnWidth); }); $(".fcTriggerReposition").error(function() { $(this).hide(); fcRepositionTiles(id, columnWidth); }); var delayer = 500; $("#"+id+" .fcChunkContent, #"+id+" .fcItemContent, #"+id+" .fcBannerContent").each(function(index) { if ($(this).css("opacity") == 0 && !$(this).is(":animated")) { $(this).delay(delayer).animate({opacity: 1.0}); delayer += 100; } }); fcRepositionTiles(id, columnWidth); tileStep++; } }); } } function fcRepositionTiles(id, width) { if (!/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { var perrow = Math.round($("#"+id).width()/width); if (perrow < 1) {perrow = 1;} var pusher = []; for (var i = 0; i < perrow; i++) pusher[i] = 0; colwidth = Math.floor($("#"+id).width()/perrow); $(".fcTile").css("width", colwidth+"px"); $(".double").css("width", (colwidth*2)+"px"); if (perrow == 1) { $("#"+id+" .fcTile").removeClass("double"); } var length = 0; $("#"+id+" .fcTile").each(function(index) { if ($(this).is(":visible")) { var shortest; for (var i = 0; i < pusher.length; i++) { if (shortest == undefined || pusher[i] < pusher[shortest]) {shortest = i;} } if (shortest == undefined) {shortest = 0;} if ($(this).hasClass("double")) { if (shortest >= (perrow-1)) { shortest = 0; } if (pusher[shortest] > pusher[shortest+1]) { pusher[shortest+1] = pusher[shortest]; } else { pusher[shortest] = pusher[shortest+1]; } pusher[shortest+1] += $(this).height(); } pusher[shortest] += $(this).height(); $(this).css("top", (pusher[shortest]-$(this).height())+"px"); $(this).css("left", (shortest*colwidth)+"px"); if (($(this).position().top+$(this).height()) > length) {length = ($(this).position().top+$(this).height());} } }); $(".fcLoadButton").css("top", (length+30)+"px"); $("#"+id).css("height", (length+120)+"px"); } }