fixed a bug in story filtering code

git-svn-id: file:///tmp/snv/trunk@11 12951d8a-c33d-4b7c-b961-822215c816e1
master
Abhinav Sarkar 2008-12-04 18:47:15 +00:00
parent 04a1088a4a
commit 4a260ec737
1 changed files with 8 additions and 5 deletions

View File

@ -133,17 +133,20 @@ var DiggSidebar = {
Application.console.log("DiggSidebar.stories.length = " + DiggSidebar.stories.length); Application.console.log("DiggSidebar.stories.length = " + DiggSidebar.stories.length);
var jp = new JPath(DiggSidebar.stories); var jp = new JPath(DiggSidebar.stories);
var filtedStories = DiggSidebar.stories; var filteredStories = jp.$(function(story){
return (story.$("category").json == DiggSidebar.endpoint.category) ;
}).json;
jp = new JPath(filteredStories);
if (DiggSidebar.endpoint.topic) if (DiggSidebar.endpoint.topic)
filtedStories = jp.$(function(story){ filteredStories = jp.$(function(story){
return story.$("topic/short_name").json == DiggSidebar.endpoint.topic; return (story.$("topic/short_name").json == DiggSidebar.endpoint.topic);
}).json; }).json;
if (DiggSidebar.endpoint.container) if (DiggSidebar.endpoint.container)
filtedStories = jp.$(function(story){ filteredStories = jp.$(function(story){
return story.$("container/short_name").json == DiggSidebar.endpoint.container; return story.$("container/short_name").json == DiggSidebar.endpoint.container;
}).json; }).json;
filtedStories.forEach(function (story, index) { filteredStories.forEach(function (story, index) {
if (index < DiggSidebar.shownStoriesCount) { if (index < DiggSidebar.shownStoriesCount) {
var now = new Date(); var now = new Date();
if (story.promote_date != null) if (story.promote_date != null)