var refresh = function() { if(document.hidden) return; $.ajax().done(function(data) { var dur = 800; var tnew = $(data).find("div > table.tborder"); var told = $("#content > div > table.tborder"); oldheight = told.height; var tidsnew = [], tidsold = [], topsnew = [], topsold = []; var top = told.offset().top; told.find(".inline_row").each(function(i, e) { e = $(e); var tid = e.find('a[id^="tid_"]').attr("id").match(/\d+/); tidsold.push(tid); topsold[tid] = e.offset().top - top; }); told.replaceWith(tnew); tnew.css("position", "relative"); tnew.find(".inline_row").each(function(i, e) { e = $(e); var tid = e.find('a[id^="tid_"]').attr("id").match(/\d+/); tidsnew.push(tid); topsnew[tid] = e.offset().top - top; }).each(function(i, e) { e = $(e); var tid = e.find('a[id^="tid_"]').attr("id").match(/\d+/); if(topsold[tid] > 0) { e.css({position: "relative", top: topsold[tid] - topsnew[tid]}).animate({top: 0}, dur); } else { e.css({textIndent: 0, transformOrigin: "50% 0%"}).animate({textIndent: 1}, {step: function(now) {$(this).css({transform: "scaleY("+now+")"})}, duration: dur}); } }); told.find(".inline_row").each(function(i, e) { e = $(e); var tid = e.find('a[id^="tid_"]').attr("id").match(/\d+/); if(typeof topsnew[tid] == "undefined") e.appendTo(tnew.children("tbody")) .css({position: "absolute", top: topsold[tid], textIndent: 1, transformOrigin: "50% 100%", width: "100%"}) .animate({textIndent: 0}, {step: function(now) {$(this).css({transform: "scaleY("+now+")"})}, complete: function() {$(this).remove();}, duration: dur}); }); }); } setInterval(refresh, 2000);