/* Copyright 2006 por Connecty Networks. Todos os direitos reservados */
function RssReader() { this.init(); this.cfg = { hasSizeBtn: false, hasRefreshBtn: false, hasSettingsBtn: false, hasDrag: false, hasProfile: false, title: "Origo - Leitor de not&iacute;cias", module: "RssReader"
}
this.domContent = { tag: "table", width: "100%", childs: [ { tag: "tr", childs: [ { tag: "td", width: "30%", childs: createTableDom([{ content: createButtonDom("Marcar como lidas", "readAll()", "widgets/rssreader/img/folder_open.gif"), width: "50px"}, { content: createButtonDom("Marcar como n&atilde;o lidas", "unReadAll()", "widgets/rssreader/img/folder_close.gif"), width: "50px"} ])
}, { tag: "td", childs: createTableDom([{ content: {tag: "div", id: "channelTitle"}, width: "100%"}, { content: {tag: "div", id: "rssPrevBtn", innerHTML: "12"}, width: "1%"}, { content: {tag: "div", id: "rssNextBtn", innerHTML: "56"}, width: "1%"} ])
}
]
}, { tag: "tr", childs: [ { tag: "td", width: "30%", childs: [ { tag: "div", id: "menu", className: "listBox", style: {width: "auto", height: "310px"}}
]
}, { tag: "td", childs: [ { tag: "div", id: "view", className: "listBox", style: {width: "auto", height: "310px"}}
]
}
]
}
]
}
this.getSignature = function() { return SYSWIDGET_WKEY+5;}
this.channelLastRefresh = null; this.onBuildInterface = function() { this.buildDomModel(this.elements.content, this.domContent); this.setTitle(this.cfg.title);}
this.buildChannel = function() { this.elements.channelTitle.innerHTML = "<h1>"+this.data.title+"</h1>"; this.elements.menu.innerHTML = ""; this.elements.view.innerHTML = ""; for(i in this.data.items) { this.buildDomModel(this.elements.menu, [{ tag: "div", className: "menu_panel", childs: [ { tag: "a", innerHTML: this.data.items[i].title.wordWrap(38), id: "menuItem"+i, href: "void", events: {onclick: "readFeed("+i+")"}, className: "listItem" + (this.data.items[i].isRead ? "visited" : "") }
]
}, { tag: "hr", width: "100%"} ]);}
}
this.readFeed = function(feedId) { this.elements.view.innerHTML = ""; this.buildDomModel(this.elements.view, [ { tag: "div", className: "menu_panel", align: "right"}, { tag: "hr", width: "100%"}, { tag: "div", className: "menu_panel", innerHTML: "<h1>"+this.data.items[feedId].title+"</H1>"+ "<p><a href='"+this.data.items[feedId]["link"]+"' target=_blank>"+this.data.items[feedId]["link"]+"</a>"+ "<p>"+(this.data.items[feedId].description ? this.data.items[feedId].description : "")
} ]); this.elements.rssPrevBtn.innerHTML = ""; this.buildDomModel(this.elements.rssPrevBtn, [ createButtonDom(false, "readFeed("+(feedId-1)+")", "widgets/rssreader/img/previous.gif", "readPrev") ]); this.elements.rssNextBtn.innerHTML = ""; this.buildDomModel(this.elements.rssNextBtn, [ createButtonDom(false, "readFeed("+(feedId+1)+")", "widgets/rssreader/img/next.gif", "readNext") ]); if(!this.data.items[feedId-1]) { hideEl(this.elements.readPrev);}
if(!this.data.items[feedId+1]) { hideEl(this.elements.readNext);}
this.data.items[feedId].isRead = true; this.elements['menuItem'+feedId].className = "listItemVisited";}
this.readAll = function() { for(i in this.data.items) { this.data.items[i].isRead = true;}
this.buildChannel();}
this.unReadAll = function() { for(i in this.data.items) { this.data.items[i].isRead = false;}
this.buildChannel();}
this.openChannel = function(widgetId, feedId) { this.data = kernel.getWidget(widgetId).data; this.widgetId = widgetId; this.buildChannel(); this.elements.icon.src = kernel.getWidget(widgetId).elements.icon.src; desktop.showPage('rssreader'); this.readFeed(feedId);}
this.close = function() { if(this.widgetId) { if(this.channelLastRefresh == kernel.getWidget(this.widgetId).lastRefresh) { kernel.getWidget(this.widgetId).data = this.data;}
}
desktop.closeCurrentPage();}
}
RssReader.prototype = new Widget();