function fcCheckNewerTiles() { if (!loadingTiles) { $.ajax({ type:"GET", data: { fcExternalAction : "fcCheckNewerTiles", fcFeedSelected : 1, fcFeeds : "1,", fcUsers : "", fcSMedias : fcSMedias, fcRefererID : "", fcSearch : "", fcKeyword : "autoimmuunisairaudet", fcCategory : "", fcYear : "", fcMonth : "", fcClientSelected : "1", fcUserSelected : "0", fcTileTypes : "items", fcTileOffset : $("#fcTiles .fcTile:first-child .fcTileOffset").val(), fcItemOffset : $("#fcTiles .fcItemOffset").first().val(), fcChunkOffset : $("#fcTiles .fcChunkOffset").first().val() }, url:"fc.output.php", success: function(data) { if (parseInt(data) > 0) { fcLoadTiles("fcTiles", $("#fcTiles .fcTile:first-child .fcTileOffset").val(), $("#fcTiles .fcItemOffset").first().val(), $("#fcTiles .fcChunkOffset").first().val(), "newer"); } } }); } } function fcLoadTiles(id, offset, item_offset, chunk_offset, direction) { if (!loadingTiles) { loadingTiles = true; $.ajax({ type:"GET", data: { fcExternalAction : "fcGetTiles", fcFeedSelected : 1, fcFeeds : "1,", fcUsers : "", fcSMedias : fcSMedias, fcRefererID : "", fcSearch : "", fcKeyword : "autoimmuunisairaudet", fcCategory : "", fcYear : "", fcMonth : "", fcClientSelected : "1", fcUserSelected : "0", fcTileTypes : "items", fcTileOffset : offset, fcItemOffset : item_offset, fcChunkOffset : chunk_offset, fcTileLimit : tilesPerLoad, fcDatetimeDirection : direction }, url:"fc.output.php", success: function(data) { loadingTiles = false; if (direction == "older") { $("#"+id).append(data); } else { $("#"+id).prepend(data); } tileOffset = $("#"+id+" .fcTile:last-child .fcTileOffset").val(); itemOffset = $("#"+id+" .fcItemOffset").last().val(); chunkOffset = $("#"+id+" .fcChunkOffset").last().val(); $(".fcTriggerReposition").load(function() { if ($(this).attr("src").indexOf("safe_image.php") >= 0) { $(this).hide(); } fcRepositionTiles(id, columnWidth); }); $(".fcTriggerReposition").error(function() { $(this).hide(); fcRepositionTiles(id, columnWidth); }); var delayer = 500; $("#"+id+" .fcChunkContent, .fcItemContent").each(function(index) { if ($(this).css("opacity") == 0 && !$(this).is(":animated")) { $(this).delay(delayer).animate({opacity: 1.0}); delayer += 100; } }); fcRepositionTiles(id, columnWidth); } }); } } function fcRepositionTiles(id, width) { 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"); feedLength = 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(); if (feedLength < pusher[shortest]+$(this).height()) { feedLength = pusher[shortest]+$(this).height(); } $(this).css("top", (pusher[shortest]-$(this).height())+"px"); $(this).css("left", (shortest*colwidth)+"px"); } }); }