changes to two functions in red
Code:
gfeedfetcher.prototype.init=function(){
this.feedsfetched=0 //reset number of feeds fetched to 0 (in case init() is called more than once)
this.feeds=[] //reset feeds[] array to empty (in case init() is called more than once)
this.feedcontainer.innerHTML='<img src="'+gfeedfetcher_loading_image+'" /> Retrieving RSS feed(s)'
var displayer=this
for (var i=0; i<this.feedurls.length; i++){ //loop through the specified RSS feeds' URLs
var feedpointer=new google.feeds.Feed(this.feedurls[i]) //create new instance of Google Ajax Feed API
var items_to_show=25;//(this.feedlimit<=this.feedurls.length)? 1 : Math.floor(this.feedlimit/this.feedurls.length) //Calculate # of entries to show for each RSS feed
if (this.feedlimit%this.feedurls.length>0 && this.feedlimit>this.feedurls.length && i==this.feedurls.length-1) //If this is the last RSS feed, and feedlimit/feedurls.length yields a remainder
items_to_show+=(this.feedlimit%this.feedurls.length) //Add that remainder to the number of entries to show for last RSS feed
feedpointer.setNumEntries(items_to_show) //set number of items to display
feedpointer.load(function(label){
return function(r){
displayer._fetch_data_as_array(r, label)
}
}(this.feedlabels[i])) //call Feed.load() to retrieve and output RSS feed.
}
}
Code:
gfeedfetcher.prototype._displayresult=function(feeds){
var rssoutput=(this.containertag[0]=="li")? "<ul>\n" : ""
gfeedfetcher._sortarray(feeds, this.sortstring)
var itemurl=[], itemtitle=[], itemlabel=[], itemdate=[], itemdescription=[]
for (var i=0; i<this.feedlimit; i++){
itemurl.push(feeds[i].link)
itemtitle.push('<span class="titlefield"><a href="' + feeds[i].link + '" target="' + this.linktarget + '">' + feeds[i].title + '</a></span>\n')
itemlabel.push(/label/i.test(this.showoptions)? '<span class="labelfield">'+this.feeds[i].ddlabel+'</span>\n' : "")
itemdate.push(gfeedfetcher._formatdate(feeds[i].publishedDate, this.showoptions))
var itemdescriptionsingle=/description/i.test(this.showoptions)? feeds[i].content : /snippet/i.test(this.showoptions)? feeds[i].contentSnippet : ""
itemdescriptionsingle=(itemdescriptionsingle!="")? '<span class="descriptionfield">' + itemdescriptionsingle + '</span>\n' : ""
itemdescription.push(itemdescriptionsingle)
}
// create temp object to store references to rss components, for access dynamically:
var holder={urlfield: itemurl, titlefield: itemtitle, labelfield: itemlabel, datefield: itemdate, descriptionfield: itemdescription}
var regexprules=this.regexprules
for (var i=(this.regexprules && this.regexprules.length>0? this.regexprules.length-1 : -1); i>=0; i--){ // loop thru regexprules array
if (regexprules[i][2]=="titlefield" || regexprules[i][2]=="labelfield" || regexprules[i][2]=="datefield" || regexprules[i][2]=="descriptionfield"){
var targetarray=holder[regexprules[i][2]] // reference array containing said field type (ie: itemdescription if regexprules[i][2]=="descriptionfield")
targetarray=targetarray.join('***delimiter***') // combine array elements before doing search and replace
.replace(regexprules[i][0], regexprules[i][1])
.split('***delimiter***') // revert back to array
holder[regexprules[i][2]]=targetarray
regexprules.splice(i,1) // remove this rule from regexprules
}
}
for (var i=0; i<this.feedlimit; i++){ // loop thru feeds, molding each feed entry based on template
rssoutput+= this.containertag[1] + this.outputtemplate.replace(/({title})|({url})|({label})|({date})|({description})/ig, function(m){
if (m == "{title}")
return holder.titlefield[i]
else if (m == "{url}")
return holder.urlfield[i]
else if (m == "{label}")
return holder.labelfield[i]
else if (m == "{date}")
return holder.datefield[i]
else if (m == "{description}")
return holder.descriptionfield[i]
}) + "</" + this.containertag[0] + ">" + "\n\n"
}
rssoutput+=(this.containertag[0]=="li")? "</ul>" : ""
for (var i=0; i<this.regexprules.length; i++){ // loop thru remaining regexprules array that target the entire feed in general (versus specific field)
rssoutput=rssoutput.replace(this.regexprules[i][0], this.regexprules[i][1])
}
this.feedcontainer.innerHTML=rssoutput
}
Bookmarks