function RSSManager(){this.ERROR_DUPLICATE_FEED=1;this.ERROR_FEED_DOES_NOT_EXIST=3;this.storm=null;this.feedList=null;this.manager=null;this.ref=null;this.version="1.1";this.sessionID=null;}RSSManager.prototype.init=function(mng,refName,handler){this.manager=mng;this.ref=refName;this.handler=handler;this.feedList=new Array;};RSSManager.prototype.addFeed=function(url){if(url==null||url.length==0){return;}this.manager.submit(this.ref+".onGetFeed","opCode=rss&sessionID="+this.sessionID+"&feed="+url);};RSSManager.prototype.onGetFeed=function(jsonRes){var newres=new Object;if(jsonRes==null){newres.status="Feed is null";newres.errorMessage="jsonRes is null";this.handler.onGetFeed(null,newres);return;}if(jsonRes==undefined){newres.status="Feed is null";newres.errorMessage="jsonRes is undefined";this.handler.onGetFeed(null,newres);return;}var res=jsonRes.json;if(res.status!="OK"){newres.status=res.status;newres.errorMessage=res.errorMessage;this.handler.onGetFeed(null,newres);return;}else{newres.status=res.status;newres.errorMessage="";var isRss=null;newres.status=res.status;var strTitle,strURL,strDesc,strDate,strLang,strOriginalURL;strTitle=unescape(res.title);strURL=res.url;strDesc=unescape(res.description);strDate=res.date;strLang=res.language;strOriginalURL=res.originalURL;var strItemTitle,strItemURL,strItemDesc,strItemDate,strItemCat,arrItems=new Array;for(var i=0;i<res.results.length;i++){strItemTitle=unescape(res.results[i].title);strItemURL=res.results[i].url;strItemDesc=res.results[i].description;if(strItemDesc!=null){strItemDesc=strItemDesc.replace(/\+/g," ");strItemDesc=decodeURIComponent(strItemDesc);strItemDesc=unescape(strItemDesc);}strItemCat=res.results[i].category;strItemDate=res.results[i].date;var item=new RSSItem(strItemTitle,strItemURL,strItemDesc,strItemCat,strItemDate);arrItems.push(item);}arrItems.push(item);var feed=new RSSFeed(strOriginalURL,strTitle,strURL,strDesc,strLang,strDate,arrItems);this.handler.onGetFeed(feed,newres);}};RSSManager.prototype.getFeedByURL=function(url){for(var i=0;i<this.feedList.length;i++){if(this.feedList[i].url==url){return this.feedList[i];}}return null;};RSSManager.prototype.addFeedToList=function(url){var obj=new Object;obj.url=url;obj.feed=null;this.feedList.push(obj);};RSSManager.prototype.removeFeed=function(url){var i=-1;for(i=0;i<this.feedList.length;i++){if(this.feedList[i].url==url){break;}}if(i==this.feedList.length){return false;}var newa=new Array;for(var j=0;j<this.feedList.length;j++){if(j==i){continue;}newa.push(this.feedList[i]);}delete this.feedList;this.feedList=null;this.feedList=newa;return true;};function RSSItem(title,url,description,category,pubDate){this.title=title;this.url=url;this.description=description;this.category=category;this.pubDate=pubDate;}RSSItem.prototype.getTitle=function(){return this.title;};RSSItem.prototype.getUrl=function(){return this.url;};RSSItem.prototype.getDescription=function(){return this.description;};RSSItem.prototype.getCategory=function(){return this.category;};RSSItem.prototype.getPubDate=function(){return this.pubDate;};function RSSFeed(strOriginalURL,strTitle,strURL,strDescription,strLanguage,strPubDate,arrItems){this.originalURL=strOriginalURL;this.title=strTitle;this.url=strURL;this.description=strDescription;this.language=strLanguage;this.pubDate=strPubDate;this.arrItems=arrItems;}RSSFeed.prototype.getFeedUrl=function(){return this.originalURL;};RSSFeed.prototype.getTitle=function(){return this.title;};RSSFeed.prototype.getSiteUrl=function(){return this.url;};RSSFeed.prototype.getDescription=function(){return this.description;};RSSFeed.prototype.getLanguage=function(){return this.language;};RSSFeed.prototype.getPubDate=function(){return this.pubDate;};RSSFeed.prototype.getItems=function(){return this.arrItems;};
