From b926f387505af6501a4afa310085880224204832 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 31 Oct 2012 23:00:40 +0400 Subject: [PATCH] further improve headline appending speed --- js/viewfeed.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/js/viewfeed.js b/js/viewfeed.js index a9c787e6e..c0cc416b6 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -116,7 +116,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) { var c = dijit.byId("headlines-frame"); var ids = getSelectedArticleIds2(); - var num_added = 0; + var new_elems = []; $("headlines-tmp").innerHTML = reply['headlines']['content']; @@ -127,15 +127,13 @@ function headlines_callback2(transport, offset, background, infscroll_req) { $$("#headlines-tmp > div").each(function(row) { if (row.className == 'cdmFeedTitle') { - row.addClassName('new'); row.style.display = 'none'; c.domNode.appendChild(row); - ++num_added; + new_elems.push(row); } else if (loaded_article_ids.indexOf(row.id) == -1) { row.style.display = 'none'; - row.addClassName('new'); c.domNode.appendChild(row); - ++num_added; + new_elems.push(row); loaded_article_ids.push(row.id); } else { row.parentNode.removeChild(row); @@ -150,9 +148,9 @@ function headlines_callback2(transport, offset, background, infscroll_req) { c.domNode.appendChild(hsp); } - console.log("added " + num_added + " headlines"); + console.log("added " + new_elems.size() + " headlines"); - if (num_added == 0) + if (new_elems.size() == 0) _infscroll_disable = true; console.log("restore selected ids: " + ids); @@ -163,9 +161,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) { initHeadlinesMenu(); - $$("#headlines-frame > div[class*=new]").each( - function(child) { - child.removeClassName('new'); + new_elems.each(function(child) { if (!Element.visible(child)) new Effect.Appear(child, { duration : 0.5 }); });