<script>
function WriteFeed(id){
this.id = id;
this.title = 128;
this.source = 128;
this.summary = 512;
this.from = "<br/> <sup>from</sup> ";
this.unique = false;
this.max = 1000;
this.except = "";
this.front = "";
this.write=function(feed){
if(this.front)
if( document.location.href != this.front ) {
document.getElementById(id).style.display="none";
return;
}
var code=[];
var lst={};
cnt = 0;
for(var i=0; i < feed.items.length; i++) {
var item = feed.items[i];
if(cnt >= this.max){
if ( lst[ this.except ] )
break;
if( item.origin.htmlUrl != this.except )
continue;
}
if(this.unique){
if( lst[item.origin.htmlUrl] )
continue;
lst[item.origin.htmlUrl] = true;
}
if(this.title)
code.push( '<a href="' + item.alternate.href + '">' + item.title.substr(0,this.title) + '</a>');
code.push( this.from );
if(this.source && item.origin.title)
code.push( '<a href="' + item.origin.htmlUrl + '">' + item.origin.title.substr(0,this.source) + '</a><br/>');
if(this.summary){
if( item.contentSnippet )
code.push( item.contentSnippet.substr(0,this.summary) + '<br/><br>' );
else if(item.summarySnippet)
code.push( item.summarySnippet.substr(0,this.summary) + '<br/><br/>' );
}
cnt++;
}
document.getElementById(id).innerHTML += code.join("");
}
}
</script>
1 comment:
Thanks for writing this.
Post a Comment