cxcskiing
10-20-2010, 07:59 PM
1) Script Title: RSSFeedsDisplayer
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex18/gajaxrssdisplayer.htm
3) Describe problem:
Hi,
You wrote:
To your question, sort by label is based on the ascending alphabetical order of the labels. I reckon you're asking how to sort by descending alphabetical order instead? If so, try finding the below line inside the .js file, and add to it the line in red:
gfeedfetcher._sortarray(feeds, this.sortstring)
feeds.reverse()
Here is the code I've got in the .js file:
gfeedfetcher._sortarray=function(arr, sortstr){
var sortstr=(sortstr=="label")? "ddlabel" : sortstr
if (sortstr=="title" || sortstr=="ddlabel"){
arr.sort(function(a,b){
var fielda=a[sortstr].toLowerCase()
var fieldb=b[sortstr].toLowerCase()
return (fielda<fieldb)? -1 : (fielda>fieldb)? 1 : 0
})
}
else{ //else, sort by "publishedDate" property (using error handling, as "publishedDate" may not be a valid date str if an error has occured while getting feed
try{
arr.sort(function(a,b){return new Date(b.publishedDate)-new Date(a.publishedDate)})
}
catch(err){}
}
}
Please advise what it should look like with the line in red. Appreciate it !
irina
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex18/gajaxrssdisplayer.htm
3) Describe problem:
Hi,
You wrote:
To your question, sort by label is based on the ascending alphabetical order of the labels. I reckon you're asking how to sort by descending alphabetical order instead? If so, try finding the below line inside the .js file, and add to it the line in red:
gfeedfetcher._sortarray(feeds, this.sortstring)
feeds.reverse()
Here is the code I've got in the .js file:
gfeedfetcher._sortarray=function(arr, sortstr){
var sortstr=(sortstr=="label")? "ddlabel" : sortstr
if (sortstr=="title" || sortstr=="ddlabel"){
arr.sort(function(a,b){
var fielda=a[sortstr].toLowerCase()
var fieldb=b[sortstr].toLowerCase()
return (fielda<fieldb)? -1 : (fielda>fieldb)? 1 : 0
})
}
else{ //else, sort by "publishedDate" property (using error handling, as "publishedDate" may not be a valid date str if an error has occured while getting feed
try{
arr.sort(function(a,b){return new Date(b.publishedDate)-new Date(a.publishedDate)})
}
catch(err){}
}
}
Please advise what it should look like with the line in red. Appreciate it !
irina