var Feeds={id:"Feeds",title:"Feeds",image:"feeds16.png",varyByFilter:true,allowItems:true,allowFolders:true,allowDrag:true,itemName:"Feed",AddDialog:"adddialog/41981707.js",UpdateDialog:"updatedialog/37324937.js",UpdateSection:"UpdateSection/54678043.js",itemClassName:"feed",_4:{},_9:new ImageSizer(0,22),_3:new ImageSizer(80,200,{minWidth:40,minHeight:40,minFileSize:100}),settings:{showFeedImage:true,showFeedDescription:false,showItemImage:true,showButtons:true,showItemAge:true,showItemDescription:true,showItemSource:true,showItemAuthor:true,maxItems:5,maxFeedItemImageWidth:80,showAllItems:false},defaultSettings:{showFeedImage:true,showFeedDescription:false,showItemImage:true,showButtons:true,showItemAge:true,showItemDescription:true,showItemSource:true,showItemAuthor:true,maxFeedImageHeight:22,maxItems:5,maxFeedItemImageWidth:80,showAllItems:false},sendEMail:function(src){var t=Feeds;var fi=t._5(src);if(fi){var cr="<br/>";var body=StringEx.joinOptional(cr+cr,"<a"+Html.attribute("href",fi.link)+">"+fi.title+"</a>",fi.description);if(page.readers=="Nexo Users"||page.readers=="Public")body+="<br/><div>Source: <a href='"+location.href+"'>"+page.title+"</a></div>";C.send({subject:fi.title,body:body})}},updateSection:function(s){Module.showDialog(Feeds,"UpdateSection",{section:s})},_7:function(item){var dv=item.dataValue;if(dv){C.beginExec("content/refresh",{item:item.nodeId})}},createItemMenuItems:function(menu,item,src){menu.add("Show Feed XML",N.openWindow,item.url);menu.add("Refresh Feed",Feeds._7,item);var e=Dom.getParentByClass(src,"feed-story");if(e&&U.un){menu.add("Send Story...",Feeds.sendEMail,src)}menu.addDivider();var label=(item.isCollapsed?"Expand Feed":"Collapse Feed");menu.add(label,Feeds._8,item)},renderEmpty:function(w,s){Section.renderEmpty(w,s)},renderSetting:function(w,settings,name,text){w("<input name=desc type=checkbox setting='",name,"' onclick='Section.setSetting(this);'");if(settings[name])w(" checked");w(" />",text,"<br/>")},addItem:function(id){Module.showDialog(Feeds,"AddDialog",{parentId:id,beforeId:-1})},insertItem2:function(parentId,beforeId,id,title,text){C.beginExec("feeds/add",{parent:parentId,beforeId:beforeId,url:id,title:title,text:text})},addItems:function(id,beforeId){if(!beforeId)beforeId=-1;Module.showDialog(Feeds,"AddDialog",{parentId:id,beforeId:beforeId})},updateItem:function(i){if(i){Module.showDialog(Feeds,"UpdateDialog",{item:page.nodes[i]})}},deleteItem:function(id){ContentItem.deleteItem(id)},defaultLayout:"Details",detailLayout:"ItemDetails",renderStyle:function(w){w(".feed {}",".feed-header { margin-top: 4px; width:100%; padding:2px; }",".feed-image { }",".feed-title { color: #000;}","a:visited.feed-title { color: #000; }",".feed-body { }",".feed-showmore {margin-top: 3px;}",".feed-story {margin-top: 3px;}",".feed-story-header {}",".feed-story-body {}",".feed-story-image {margin: 0 5px 5px 0;}",".feed-story-title {text-decoration:underline;}","a:visited.feed-story-title {color: rgb(102,102,204);}",".feed-story-buttons {white-space:nowrap;}",".feed-story-age {",FontSize.xs,"white-space:nowrap; text-overflow:ellipsis; overflow: hidden;}",".feed-story-desc {",FontSize.s,"}",".feed-story-source {",FontSize.xs,"white-space:nowrap;}",".feed-story-author {",FontSize.xs,"white-space:nowrap; }",".feed-tip-image {float:right; margin: 2px; border: 1px solid gray;}")},layouts:{Summary:{settings:{showFeedImage:false,showFeedDescription:false,showItemImage:false,showButtons:true,showItemAge:true,showItemDescription:false,showItemSource:false,showItemAuthor:false,maxItems:5,showAllItems:false},renderItemContent:function(w,item){Feeds.renderItemContent(w,item,this.settings)}},Details:{settings:{showFeedImage:true,showFeedDescription:false,showItemImage:true,showButtons:true,showItemAge:true,showItemDescription:true,showItemSource:true,showItemAuthor:true,maxItems:5,showAllItems:false},renderItemContent:function(w,item){Feeds.renderItemContent(w,item,this.settings)}},ItemDetails:{kind:1,settings:{showFeedImage:true,showFeedDescription:true,showItemImage:true,showButtons:true,showItemAge:true,showItemDescription:true,showItemSource:true,showItemAuthor:true,maxItems:-1,overrideSection:true,showAllItems:true},renderItemContent:function(w,item){Feeds.renderItemContent(w,item,this.settings)}}},renderItemDivider:function(w){},renderItemContent:function(w,item,settings){if(item.dataBinding)item.dataBinding.dispose();var uri=item.dataId;var id=Dom.getElementId(item);item.dataValue=DataManager.getValue(item.dataId);item.dataBinding=new DataBinding(this,item.dataValue,id,item);item.section.contentDispose.push(item.dataBinding);var title=item.title;var feed=item.dataValue.value;this.writeItem(w,item.section,feed,title,item,settings)},_6:function(items){var startTime=(window.Filter)?Filter.filterStartTime:null;var result=[];if(items){var now=new Date();var nowTime=now.getTime();for(var i=0;i<items.length;i++){var item=items[i];var add=true;var dt=Date.fromSeconds(item.pubDate);if(item.createDate&&item.pubDate&&dt){var dt2=Date.fromSeconds(Math.max(item.createDate,item.pubDate));item.age=nowTime-dt.getTime();if(startTime)add=dt2>=startTime}if(add){result[result.length]=item}}}return result},writeItem:function(w,s,feed,title,node,settings){var h=HtmlFactory;var now=new Date();var nowTime=now.getTime();var image;if(!settings)settings=s.settings;if(feed){var items=(settings.showAllItems?feed.items:Feeds._6(feed.items));w("<table class=feed-header><tr><td>");if(settings.showFeedImage&&feed.image&&feed.image.url){image=feed.image;w("&nbsp;");Feeds._9.render(w,{className:"feed-image",align:"absMiddle",src:image.url});w("&nbsp;")}title=title||feed.title;if(feed.link){w("<a class=feed-title href='"+feed.link+"' target='"+A.targetWindowName+"' tip='feed:'>",title||"Untitled","</a>")}else{w("<span class=feed-title tip='feed:'>",title,"</span>")}w("</td></tr></table>");if(items&&items.length>0){w("<div class=feed-body",((node.isCollapsed)?" style='display:none'":""),">");var count=items.length;var maxItems=(s.maxItems?s.maxItems:5);if(settings.overrideSection){maxItems=settings.maxItems}var showMax=count;if(maxItems!=-1){showMax=count.constrain(0,maxItems)}var showCount=0;w("<div class=feedGroup>");var item;var j;for(j=0;j<showMax;j++){item=items[j];showCount++;this.writeFeedItem(w,settings,item,now,j)}for(var i=0;i<items.length;i++){item=items[i];var key=item.link||item.title;Feeds._4[key]=true}w("</div>");if(showCount<count){if(node.isMoreExpanded){w("<div class='feed-showmore printHide font-sys'>","<a href='' onclick='Feeds.showMore(this);return false;' showCount='",showCount,"'>Hide ",count-showCount," More</a>","<img src='",A.imagesBase,"collapsearrowup.gif' align=absmiddle /></div>");w("<div class=feedGroup>");for(j=showMax;j<count;j++){item=items[j];showCount++;this.writeFeedItem(w,settings,item,now,j)}w("</div>")}else{w("<div class='feed-showmore printHide font-sys'>","<a href='' onclick='Feeds.showMore(this);return false;' showCount='",showCount,"'>Show ",count-showCount," More</a>","<img src='",A.imagesBase,"collapsearrowdown.gif' align=absmiddle /></div>");w("<div class=feedGroup style='display:none;' feedOffset='"+showCount+"'></div>")}}w("</div>")}}},_8:function(item){if(item.isCollapsed){item.isCollapsed=false}else{item.isCollapsed=true}var e=Dom.getByNode(item);var feedBodyDiv=Dom.getChildElement(e,"DIV");Dom.toggleCollapse(feedBodyDiv,null)},toggleCollapse:function(e,id){var item=page.nodes[id];if(item){if(item.isCollapsed){item.isCollapsed=false}else{item.isCollapsed=true}Dom.collapse(e,1)}},showMore:function(e){var t=e.parentNode.nextSibling;if(t){var item;var offset=t.getAttribute("feedOffset");if(offset){var feed=Feeds._1(t);var now=new Date();var nowTime=now.getTime();var sb=new StringBuilder();var w=sb.write;var items=Feeds._6(feed.items);if(items.length>0){var layout=Section.getCurrent(e).layout;for(var j=offset;j<items.length;j++){item=items[j];this.writeFeedItem(w,layout.settings,item,now,j)}}t.setAttribute("feedOffset",null);t.innerHTML=sb.toString()}item=Feeds._12(t);var img=e.nextSibling;var count=e.innerHTML.substring(4);if(Dom.toggleCollapse(t)){img.src=A.imagesBase+"collapsearrowup.gif";e.innerHTML="Hide"+count;item.isMoreExpanded=true}else{img.src=A.imagesBase+"collapsearrowdown.gif";e.innerHTML="Show"+count;item.isMoreExpanded=false}}},writeFeedItem:function(w,settings,item,now,index){var hasImage=false;w("<div class=feed-story feedItem='"+index+"'>");if(settings.showItemImage){var image=item.image;if(image&&image.src&&!Feeds._3.isHidden(image)){if(Feeds._3.render(w,{className:"feed-story-image",src:image.src,align:"left"})){hasImage=true}}}w("<div class='feed-story-header'>",ImageEx.formatImg(A.imagesBase+"trianglebullet.png",5,9,{"class":"trianglebullet"}));var itemTitle=item.title;if(item.link){w("<a class=feed-story-title href='",item.link,"' target='"+A.targetWindowName+"' tip='feed-story:'>",itemTitle||"Untitled","</a>")}else{w("<span class=feed-story-title tip='feed-story:'>",itemTitle,"</span>")}if(settings.showButtons){w("<span class='feed-story-buttons printHide'>&nbsp;");CommandBar.renderImg(w,5,"Feeds.sendEMail(this)",{alt:"Send Story"});w("</span>")}if(settings.showItemAge){if(item.age&&item.pubDate){var ageDate=Date.fromSeconds(item.pubDate);if(ageDate){var ageElement=new AgeBinding(ageDate);w(" <span class='feed-story-age font-sys color-red'>- <span id='",ageElement.id,"'>",ageElement.text,"</span> ago</span>")}}}w("</div>");var body="";if(settings.showItemDescription&&item.description){var desc=item.description.replace(/&amp;#151;/g,"&#151;");body+="<span class=feed-story-desc>"+desc+"</span>"}if(settings.showItemSource&&item.source){body+=" <span class='feed-story-source color-lightest'>"+item.source+"</span>"}if(settings.showItemAuthor&&item.author){body+=" <span class='feed-story-author color-lightest'>- By "+item.author+"</span>"}if(body.length>0){w("<div class=feed-story-body>",body,"</div>")}if(hasImage){w("<div class=clear>&nbsp;</div>")}w("</div>")},onDataChanged:function(b){if(b){var feed=b.value;var s=b.item.section;var newItems=[];var displayedItems=Feeds._4;var i;var key;if(feed&&feed.items&&feed.items.length>0){for(i=0;i<feed.items.length;i++){var item=feed.items[i];key=item.link||item.title;if(!displayedItems[key]){newItems.push(key)}}}var sb=new StringBuilder();this.writeItem(sb.write,s,feed,b.item.title,b.item);b.element.innerHTML=sb.toString();var feedElement=b.element;for(i=0;i<newItems.length;i++){key=newItems[i];var e=Dom.getChildElement(feedElement,"A",{href:key});if(!e)e=Dom.getChildElement(feedElement,"SPAN",{innerHTML:key});Animation.fadeBackground(e,Style.changedBackColor)}}},_12:function(src){var item=null;if(src){var e=Dom.getParentByClass(src,"feed");if(e){item=Dom.getNode(e)}}return item},_1:function(src){var feed=null;if(src){var e=Dom.getParentByClass(src,"feed");if(e){var item=Dom.getNode(e);if(item)feed=item.dataValue.value}}return feed},_5:function(src){var item=null;var feed=Feeds._1(src);if(feed){var e=Dom.getParentByAttribute(src,"feedItem");if(e){var index=e.getAttribute("feedItem");item=feed.items[index]}}return item},_0:function(time){if(time){var d=Date.fromSeconds(time);return(d?Date.formatAge(d)+" ago":"")}else{return null}},_2:function(value,label){if(value){return"<span class=output-label>"+label+": </span>"+value}else{return null}},_11:function(feed){var t=Feeds;var prefix="<p style='width:400px;'>";var suffix="</p>";var opt=t._2;var desc="";var img=feed.image;if(img){desc="<img class=feed-tip-image src='"+img.url+"'"+((img.width>0)?" width="+img.width:"")+((img.height>0)?" height="+img.height:"")+" />"}if(feed.description)desc+=feed.description;var props=StringEx.joinOptional("<br />",opt(feed.category,"Category"),opt(feed.rating,"Rating"),opt(t._0(feed.pubDate),"Published"),opt(t._0(feed.timeLoaded),"Loaded"));return"<table style='width:400px;'><tr valign=top>"+"<td width=16px>"+ImageEx.formatImg(A.imagesBase+"feed16.png",16,16)+"</td>"+"<td><b>"+(feed.title||"")+"</b></td>"+"</tr></table>"+StringEx.optional(desc,prefix,suffix)+StringEx.optional(feed.copyright,prefix,suffix)+StringEx.optional(props,prefix,suffix)},_10:function(item){var t=Feeds;var prefix="<p style='width:400px;'>";var suffix="</p>";var opt=t._2;var props=StringEx.joinOptional("<br />",opt(item.author,"Author"),opt(item.category,"Category"),opt(item.source,"Source"),opt(t._0(item.pubDate),"Published"),opt(t._0(item.createDate),"Loaded"));return"<table style='width:400px;'><tr valign=top>"+"<td width=16px>"+ImageEx.formatImg(A.imagesBase+"feed16.png",16,16)+"</td>"+"<td><b>"+(item.title||"")+"</b></td>"+"</tr></table>"+StringEx.optional(item.description,prefix,suffix)+StringEx.optional(props,prefix,suffix)},onTip:function(evt){var tip=evt.tip;if(tip.startsWith("feed:")){evt.tip="";var feed=Feeds._1(evt.element);if(feed){evt.tip=Feeds._11(feed)}}else if(tip.startsWith("feed-story:")){evt.tip="";var item=Feeds._5(evt.element);if(item){evt.tip=Feeds._10(item)}}}};Module.add(Feeds);