[Pkg-mozext-commits] [sage-extension] 01/39: feed parsing overhaul

David Prévot taffit at moszumanska.debian.org
Fri May 1 03:10:18 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to tag sage_1_1
in repository sage-extension.

commit 9e0e6e8810fcc7e7cd7e286eef928cd3abf56b6a
Author: Peter Andrews <petea at jhu.edu>
Date:   Sat May 29 04:42:16 2004 +0000

    feed parsing overhaul
---
 src/install.js                 |   2 +-
 src/sage/content/createhtml.js |  52 +++----
 src/sage/content/feedlib.js    | 313 +++++++++++++++++++++++++++++++++++++++++
 src/sage/content/sage.js       | 259 ++++++----------------------------
 src/sage/content/sage.xul      |   1 +
 src/sage/locale/en-US/sage.dtd |   2 +-
 src/sage/locale/ja-JP/sage.dtd |   2 +-
 7 files changed, 384 insertions(+), 247 deletions(-)

diff --git a/src/install.js b/src/install.js
index ca5fc05..feaae61 100755
--- a/src/install.js
+++ b/src/install.js
@@ -1,6 +1,6 @@
 const APP_NAME			= "Sage";
 const APP_CHROME_NAME		= "sage";
-const APP_VERSION		= "1.0";
+const APP_VERSION		= "1.1";
 const APP_FILE 			= "sage.jar";
 const APP_CONTENTS_PATH		= "content/";
 const APP_SKIN_CLASSIC_PATH	= "skin/classic/";
diff --git a/src/sage/content/createhtml.js b/src/sage/content/createhtml.js
index 3a3f3cd..2138d7c 100755
--- a/src/sage/content/createhtml.js
+++ b/src/sage/content/createhtml.js
@@ -10,20 +10,20 @@ var CreateHTML = {
 
 	set tabbed(aValue){ this._tabbed = aValue },
 
-	openHTML: function(aRssObject){
-		if(!aRssObject) return;
+	openHTML: function(feed) {
+		if(!feed) return;
 
-		try{
-			var htmlURL = this.createHTML(aRssObject);
-			if(this._tabbed){
+		try {
+			var htmlURL = this.createHTML(feed);
+			if(this._tabbed) {
 				getContentBrowser().addTab(htmlURL);
-			}else{
+			} else {
 				getContentBrowser().loadURI(htmlURL);
 			}
-		}catch(e){}
+		} catch(e) {}
 	},
 
-	createHTML: function(aRssObject){
+	createHTML: function(feed) {
 		var tmpFile = this.getSpecialDir("UChrm");
 		tmpFile.appendRelativePath("sage.html");
 
@@ -31,7 +31,7 @@ var CreateHTML = {
 							.getService(Components.interfaces.nsIIOService);
 		var xmlFilePath = ioService.newFileURI(tmpFile).spec;
 
-		if(tmpFile.exists()){
+		if(tmpFile.exists()) {
 			tmpFile.remove(true);
 		}
 		tmpFile.create(tmpFile.NORMAL_FILE_TYPE, 0666);
@@ -40,7 +40,7 @@ var CreateHTML = {
 						.createInstance(Components.interfaces.nsIFileOutputStream);
 		stream.init(tmpFile, 2, 0x200, false); // open as "write only"
 		
-		var content = this.createHTMLSource(aRssObject);
+		var content = this.createHTMLSource(feed);
 		stream.write(content, content.length);
 		stream.flush();
 		stream.close();
@@ -48,7 +48,7 @@ var CreateHTML = {
 		return xmlFilePath;
 	},
 
-	getUserCssURL: function(){
+	getUserCssURL: function() {
 		var userCssEnable = CommonFunc.getPrefValue(this.USER_CSS_ENABLE, "bool", false);
 		var userCssPath = CommonFunc.getPrefValue(this.USER_CSS_PATH, "wstr", "");
 		if(!userCssEnable || !userCssPath) return null;
@@ -57,41 +57,41 @@ var CreateHTML = {
 							.getService(Components.interfaces.nsIIOService);
 		var tmpFile = Components.classes['@mozilla.org/file/local;1']
 							.createInstance(Components.interfaces.nsILocalFile);
-		try{		
+		try {		
 			tmpFile.initWithPath(userCssPath);
 			var cssUrl = ioService.newFileURI(tmpFile);
 			var contentType = ioService.newChannelFromURI(cssUrl).contentType;
 			if(contentType != "text/css") return null;
 
 			return cssUrl.spec;
-		}catch(e){
+		} catch(e) {
 			return null;
 		}
 	},
 
-	createHTMLSource: function(aRssObject){
+	createHTMLSource: function(feed) {
 		var allowEContent = CommonFunc.getPrefValue(this.ALLOW_ENCODED_CONTENT, "bool", false);
 
 		var htmlSource = this.HTML_SOURCE;
 		var cssUrl	= this.getUserCssURL();
-		if(cssUrl){
+		if(cssUrl) {
 			htmlSource = htmlSource.replace("**CSSURL**", cssUrl);
-		}else{
+		} else {
 			htmlSource = htmlSource.replace("**CSSURL**", this.DEFAULT_CSS);
 		}
-		htmlSource = htmlSource.replace("**HTMLTITLE**", aRssObject.title);
-		htmlSource = htmlSource.replace("**TITLE**", aRssObject.title);
-		htmlSource = htmlSource.replace("**LINK**", aRssObject.link);
-		htmlSource = htmlSource.replace("**DESCRIPTION**", aRssObject.description);
+		htmlSource = htmlSource.replace("**HTMLTITLE**", feed.getTitle());
+		htmlSource = htmlSource.replace("**TITLE**", feed.getTitle());
+		htmlSource = htmlSource.replace("**LINK**", feed.getLink());
+		htmlSource = htmlSource.replace("**DESCRIPTION**", feed.getDescription());
 
 		var itemsSource = "";
-		for(var i=0; i<aRssObject.items.length; i++){
-			var link = aRssObject.items[i].link;
-			var title = aRssObject.items[i].title;
+		for(var i = 0; i < feed.getItemCount(); i++) {
+			var link = feed.getItem(i).getLink();
+			var title = feed.getItem(i).getTitle();
 			
-			var description = allowEContent ? aRssObject.items[i].content : aRssObject.items[i].description;
+			var description = allowEContent ? feed.getItem(i).getContent() : htmlToText(feed.getItem(i).getContent());
 
-			var pubDate = aRssObject.items[i].pubDate;
+			var pubDate = feed.getItem(i).getPubDate();
 	
 			if(!title)
 				title = "No Title";
@@ -115,7 +115,7 @@ var CreateHTML = {
 		return CommonFunc.convertCharCodeFrom(htmlSource, "UTF-8");
 	},
 
-	getSpecialDir: function(aProp){
+	getSpecialDir: function(aProp) {
 		var dirService = Components.classes['@mozilla.org/file/directory_service;1']
 							.getService(Components.interfaces.nsIProperties);
 		return dirService.get(aProp, Components.interfaces.nsILocalFile);
diff --git a/src/sage/content/feedlib.js b/src/sage/content/feedlib.js
new file mode 100644
index 0000000..455df87
--- /dev/null
+++ b/src/sage/content/feedlib.js
@@ -0,0 +1,313 @@
+var Feed = {
+
+	feedXML: null,
+	feedFormat: null,
+
+	title: null,
+	link: null,
+	description: null,  
+	items: new Array(),
+  lastPubDate: null,
+
+
+	Feed: function(feedXML) {
+		this.feedXML = feedXML;
+
+		if(!feedXML) {
+			throw "Empty Feed";
+		}
+
+		var rootNodeName = feedXML.documentElement.localName.toLowerCase();
+		if(rootNodeName == "feed") {
+			this.parseATOM();
+		} else {
+			this.parseRSS();
+		}
+	},
+
+	parseRSS: function() {
+
+		feedXML = this.feedXML;
+
+		this.feedFormat = "RSS";
+
+		var channelNode;
+		if(feedXML.getElementsByTagName("channel").length != 0) {
+			channelNode = feedXML.getElementsByTagName("channel")[0];
+		} else {
+			throw "No elements in channel tag";
+		}
+
+		for(var i = channelNode.firstChild; i != null; i = i.nextSibling) {
+			if(i.nodeType != i.ELEMENT_NODE) continue;
+			switch(i.localName) {
+				case "title":
+					this.title = CommonFunc.getInnerText(i);
+					break;
+				case "link":
+					this.link = CommonFunc.getInnerText(i);
+					break;
+				case "description":
+					this.description = CommonFunc.getInnerText(i);
+					break;
+			}
+		}
+
+		var itemNodes = feedXML.getElementsByTagName("item");
+		for(i = 0; itemNodes.length > i; i++) {
+			var item = {title:"", link:"", content:"", pubDate:""};
+
+			for(var j = itemNodes[i].firstChild; j!=null; j=j.nextSibling) {
+				if(j.nodeType != j.ELEMENT_NODE) continue;
+				switch(j.localName) {
+					case "title":
+						item.title = CommonFunc.getInnerText(j);
+						break;
+					case "link":
+						item.link = CommonFunc.getInnerText(j);
+						break;
+					case "guid":
+						if(!item.link) {
+							item.link = CommonFunc.getInnerText(j);
+						}
+						break;
+					case "encoded":
+						item.content = CommonFunc.getInnerText(j);
+						break;
+					case "pubDate":
+						item.pubDate = new Date(CommonFunc.getInnerText(j));
+						break;
+					case "date":
+						tmp_str = CommonFunc.getInnerText(j);
+						tmp_date = new Date();
+						tmp_date.setUTCFullYear(tmp_str.substring(0,4));
+						tmp_date.setUTCMonth(tmp_str.substring(5,7) - 1);
+						tmp_date.setUTCDate(tmp_str.substring(8,10));
+						tmp_date.setUTCHours(tmp_str.substring(11,13));
+						tmp_date.setUTCMinutes(tmp_str.substring(14,16));
+						tmp_date.setUTCSeconds(tmp_str.substring(17,19));
+						item.pubDate = new Date(tmp_date);
+						break;
+				}
+			}
+
+			var tmpFeedItem = new FeedItem(item.title, item.link, item.content, item.pubDate);
+
+			if(tmpFeedItem.hasPubDate()) {
+				if(tmpFeedItem.getPubDate() > this.lastPubDate) {
+					this.lastPubDate = tmpFeedItem.getPubDate();
+				}
+			}
+
+			this.items.push(tmpFeedItem);
+		}
+	},
+
+	parseATOM: function() {
+
+		feedXML = this.feedXML;
+
+		this.feedFormat = "ATOM";
+
+		for(var i = feedXML.documentElement.firstChild; i != null; i = i.nextSibling){
+			if(i.nodeType != i.ELEMENT_NODE) continue;
+			switch(i.localName){
+				case "title":
+					this.title = CommonFunc.getInnerText(i);
+					break;
+				case "link":
+					if(this.link) {
+						if(i.getAttribute("rel").toLowerCase() == "alternate"){
+							this.link = i.getAttribute("href");
+						}
+					} else {
+						this.link = i.getAttribute("href");
+					}
+					break;
+				case "tagline":
+					this.description = CommonFunc.getInnerText(i);
+					break;
+			}
+		}
+
+		var entryNodes = feedXML.getElementsByTagName("entry");
+		for(i = 0; entryNodes.length > i; i++){
+			var item = {title:"", link:"", content:"", pubDate:""};
+
+			var titleNodes = entryNodes[i].getElementsByTagName("title");
+			if(titleNodes.length) {
+				item.title = CommonFunc.getInnerText(titleNodes[0]);
+			}
+
+			var linkNodes = entryNodes[i].getElementsByTagName("link");
+			if(linkNodes.length) {
+				for (j = 0; j < linkNodes.length; j++) {
+					if (linkNodes[j].getAttribute("rel") == "alternate") {
+						item.link = linkNodes[j].getAttribute("href");
+						break;
+					}
+				}
+			}
+
+			var issuedNodes = entryNodes[i].getElementsByTagName("issued");
+			if(issuedNodes.length) {
+				tmp_str = CommonFunc.getInnerText(issuedNodes[0]);
+				tmp_date = new Date();
+				tmp_date.setUTCFullYear(tmp_str.substring(0,4));
+				tmp_date.setUTCMonth(tmp_str.substring(5,7) - 1);
+				tmp_date.setUTCDate(tmp_str.substring(8,10));
+				tmp_date.setUTCHours(tmp_str.substring(11,13));
+				tmp_date.setUTCMinutes(tmp_str.substring(14,16));
+				tmp_date.setUTCSeconds(tmp_str.substring(17,19));
+				item.pubDate = new Date(tmp_date);
+			}
+
+			var aEntryNode = entryNodes[i];
+
+			var contentNodes = aEntryNode.getElementsByTagName("content");
+			var contentArray = new Array();
+			for(var i=0; i<contentNodes.length; i++){
+				var contType = contentNodes[i].getAttribute("type");
+				contentArray[contType] = CommonFunc.getInnerText(contentNodes[i]);
+			}
+
+			var summaryNodes = aEntryNode.getElementsByTagName("summary");
+
+			if("application/xhtml+xml" in contentArray) {
+				item.content = contentArray["application/xhtml+xml"];
+			} elseif("text/html" in contentArray) {
+				item.content = contentArray["text/html"];
+			} elseif("text/plain" in contentArray) {
+				item.content = contentArray["text/plain"];
+			}	elseif(summaryNodes.length) {
+				item.content = CommonFunc.getInnerText(summaryNodes[0]);
+			}
+			
+			var tmpFeedItem = new FeedItem(item.title, item.link, item.content, item.pubDate);
+
+			if(tmpFeedItem.hasPubDate()) {
+				if(tmpFeedItem.getPubDate() > this.lastPubDate) {
+					this.lastPubDate = tmpFeedItem.getPubDate();
+				}
+			}
+
+			this.items.push(tmpFeedItem);
+		}
+	},
+
+	getTitle: function() {
+		return this.title;
+	}
+
+	getDescription: function() {
+		return this.description;
+	}
+
+	getLink: function() {
+		return this.link;
+	}
+
+	hasLastPubDate: function() {
+		if(this.lastPubDate) {
+			return true;
+		} else {
+			return false;
+		}
+	}
+
+	getLastPubDate: function() {
+		if(this.hasLastPubDate()) {
+			return this.lastPubDate;
+		} else {
+			return null;
+		}
+	},
+
+	getItemCount: function() {
+		return this.items.length;
+	},
+
+	getItem: function(itemIndex) {
+		return this.items[itemIndex];
+	},
+
+	getFormat: function() {
+		return this.feedFormat;
+	},
+
+}
+
+
+var FeedItem = {
+
+	title: null,
+	link: null,
+	content: null,
+  pubDate: null,
+
+	FeedItem: function(title, link, content, pubDate) {
+		this.title = title;
+		this.link = link;
+		this.content = content;
+		this.pubDate = pubDate;
+	},
+
+	hasTitle: function() {
+		if(!this.title) {
+			return false;
+		} else {
+			return true;
+		}
+	},
+
+	getTitle: function() {
+		if(this.hasTitle()) {
+			return this.title;
+		} else {
+			if(this.hasContent()) {
+				temp = this.getContent();
+				temp.replace(/<.*?>/g,'');
+				return temp.substring(0, 30) + "...";
+			} else {
+				return "No Title";
+			}
+		}
+	},
+
+	getLink: function() {
+		return this.link;
+	},
+
+	hasContent: function() {
+		if(this.content) {
+			return true;
+		} else {
+			return false;
+		}
+	},
+
+	getContent: function() {
+		if(this.hasContent()) {
+			return this.content;
+		} else {
+			return "No content";
+		}
+	},
+
+	hasPubDate: function() {
+		if(this.pubDate) {
+			return true;
+		} else {
+			return false;
+		}
+	},
+
+	getPubDate: function() {
+		if(this.hasPubDate()) {
+			return this.pubDate;
+		} else {
+			return null;
+		}
+	},
+
+}
\ No newline at end of file
diff --git a/src/sage/content/sage.js b/src/sage/content/sage.js
index 4bf1187..85938ec 100755
--- a/src/sage/content/sage.js
+++ b/src/sage/content/sage.js
@@ -18,7 +18,7 @@ var rssStatusLabel;
 var rssTitleLabel;
 var rssItemListPopup;
 
-var rssObject;
+var currentFeed;
 var httpReq;
 var prefObserverSageFolder;
 var responseXML;
@@ -206,7 +206,7 @@ function rssItemListBoxClick(aEvent){
 	}
 
 	var selectedItem = rssItemListBox.selectedItem;
-	var link = rssObject.items[selectedItem.value].link;
+	var link = currentFeed.getItem(selectedItem.value).getLink();
 	var tabbed = false;
 
 	if(aEvent.button == 1){ tabbed = true; } // click middle button
@@ -250,11 +250,11 @@ function setStatusDone(){
 	rssStatusImage.setAttribute("loading", "false");
 	rssStatusLabel.value = "";
 
-	if(rssObject){
-		rssTitleLabel.value = htmlToText(rssObject.title);
-		if(rssObject.link){
-			rssTitleLabel.setAttribute("href", rssObject.link);
-			rssTitleLabel.tooltipText = rssObject.link;
+	if(currentFeed){
+		rssTitleLabel.value = htmlToText(currentFeed.getTitle());
+		if(currentFeed.getLink()){
+			rssTitleLabel.setAttribute("href", currentFeed.getLink());
+			rssTitleLabel.tooltipText = currentFeed.getLink();
 		}else{
 			rssTitleLabel.removeAttribute("href");
 			rssTitleLabel.tooltipText = "";
@@ -279,184 +279,6 @@ function getContentBrowser(){
 	return null;
 }
 
-
-	// RSS
-function createRssObject(){
-	if(!responseXML){ return; }
-	
-	rssObject = {
-		rssURL: lastResource.url,
-		title: "",
-		link: "",
-		description: "",
-		charSet: responseXML.characterSet,
-		items: new Array()
-	}
-
-	var rootNodeName = responseXML.documentElement.localName.toLowerCase();
-	if(rootNodeName == "feed"){
-		createRssObjectAtom();
-		return;
-	}
-
-	var channelNode;
-	if(responseXML.getElementsByTagName("channel").length != 0){
-		channelNode = responseXML.getElementsByTagName("channel")[0];
-	}else{
-		return;
-	}
-
-	for(var i = channelNode.firstChild; i!=null; i=i.nextSibling){
-		if(i.nodeType != i.ELEMENT_NODE) continue;
-		switch(i.localName){
-			case "title":
-				rssObject.title = CommonFunc.getInnerText(i);
-				break;
-			case "link":
-				rssObject.link = CommonFunc.getInnerText(i);
-				break;
-			case "description":
-				rssObject.description = CommonFunc.getInnerText(i);
-				break;
-		}
-	}
-
-	var itemNodes = responseXML.getElementsByTagName("item");
-	for(i=0; itemNodes.length>i; i++){
-		var rssItem = {title:"", link:"", description:"", content:"", pubDate:""};
-
-		for(var j = itemNodes[i].firstChild; j!=null; j=j.nextSibling){
-			if(j.nodeType != j.ELEMENT_NODE) continue;
-			switch(j.localName){
-				case "title":
-					rssItem.title = CommonFunc.getInnerText(j);
-					break;
-				case "link":
-					rssItem.link = CommonFunc.getInnerText(j);
-					break;
-				case "guid":
-					if(!rssItem.link){
-						rssItem.link = CommonFunc.getInnerText(j);
-					}
-					break;
-				case "description":
-					rssItem.description = CommonFunc.getInnerText(j);
-					break;
-				case "encoded":
-					rssItem.content = CommonFunc.getInnerText(j);
-					break;
-				case "pubDate":
-					rssItem.pubDate = new Date(CommonFunc.getInnerText(j));
-					break;
-				case "date":
-					tmp_str = CommonFunc.getInnerText(j);
-					tmp_date = new Date();
-					tmp_date.setUTCFullYear(tmp_str.substring(0,4));
-					tmp_date.setUTCMonth(tmp_str.substring(5,7) - 1);
-					tmp_date.setUTCDate(tmp_str.substring(8,10));
-					tmp_date.setUTCHours(tmp_str.substring(11,13));
-					tmp_date.setUTCMinutes(tmp_str.substring(14,16));
-					tmp_date.setUTCSeconds(tmp_str.substring(17,19));
-					rssItem.pubDate = new Date(tmp_date);
-					break;
-			}
-		}
-			// title �������Ƃ��̏���
-		if(!rssItem.title) {
-			if(rssItem.description) {
-				tempStr = rssItem.description.replace(/<.*?>/g,'');
-				rssItem.title = tempStr.substring(0, 30) + "...";
-			}
-		}
-			// content �������Ƃ��̏���
-		if(!rssItem.content) rssItem.content = rssItem.description;
-			// description ��v���[���e�L�X�g�ɂ���
-		rssItem.description = htmlToText(rssItem.description);
-
-		rssObject.items.push(rssItem);
-	}
-}
-
-
-	// ATOM
-function createRssObjectAtom(){
-	for(var i = responseXML.documentElement.firstChild; i!=null; i=i.nextSibling){
-		if(i.nodeType != i.ELEMENT_NODE) continue;
-		switch(i.localName){
-			case "title":
-				rssObject.title = CommonFunc.getInnerText(i);
-				break;
-			case "link":
-				if(rssObject.link){
-					if(i.getAttribute("rel") == "alternate"){
-						rssObject.link = i.getAttribute("href");
-					}
-				}else{
-					rssObject.link = i.getAttribute("href");
-				}
-				break;
-			case "tagline":
-				rssObject.description = CommonFunc.getInnerText(i);
-				break;
-		}
-	}
-
-	var entryNodes = responseXML.getElementsByTagName("entry");
-	for(i=0; entryNodes.length>i; i++){
-		var rssItem = {title:"", link:"", description:"", content:"", pubDate:""};
-
-		var titleNodes = entryNodes[i].getElementsByTagName("title");
-		if(titleNodes.length) rssItem.title = CommonFunc.getInnerText(titleNodes[0]);
-
-		var linkNodes = entryNodes[i].getElementsByTagName("link");
-		if(linkNodes.length) {
-			for (j = 0; j < linkNodes.length; j++) {
-				if (linkNodes[j].getAttribute("rel") == "alternate") {
-					rssItem.link = linkNodes[j].getAttribute("href");
-					break;
-				}
-			}
-		}
-
-
-		var issuedNodes = entryNodes[i].getElementsByTagName("issued");
-		if(issuedNodes.length) {
-			tmp_str = CommonFunc.getInnerText(issuedNodes[0]);
-			tmp_date = new Date();
-			tmp_date.setUTCFullYear(tmp_str.substring(0,4));
-			tmp_date.setUTCMonth(tmp_str.substring(5,7) - 1);
-			tmp_date.setUTCDate(tmp_str.substring(8,10));
-			tmp_date.setUTCHours(tmp_str.substring(11,13));
-			tmp_date.setUTCMinutes(tmp_str.substring(14,16));
-			tmp_date.setUTCSeconds(tmp_str.substring(17,19));
-			rssItem.pubDate = new Date(tmp_date);
-		}
-
-		rssItem.content = getAtomContent(entryNodes[i]);
-		rssItem.description = htmlToText(rssItem.content);
-		rssObject.items.push(rssItem);
-	}
-}
-
-
-function getAtomContent(aEntryNode){
-	var contentNodes = aEntryNode.getElementsByTagName("content");
-	var contentArray = new Array();
-	for(var i=0; i<contentNodes.length; i++){
-		var contType = contentNodes[i].getAttribute("type");
-		contentArray[contType] = CommonFunc.getInnerText(contentNodes[i]);
-	}
-
-	if("application/xhtml+xml" in contentArray) return contentArray["application/xhtml+xml"];
-	if("text/html" in contentArray) return contentArray["text/html"];
-	if("text/plain" in contentArray) return contentArray["text/plain"];
-
-	var summaryNodes = aEntryNode.getElementsByTagName("summary");
-	if(summaryNodes.length) return CommonFunc.getInnerText(summaryNodes[0]);
-
-	return "";
-}
-
 function toggleShowSearchBar() {
 	var showSearchBar = getCheckboxCheck("chkShowSearchBar");
 	document.getElementById("barSearch").hidden = !showSearchBar;
@@ -470,22 +292,22 @@ function toggleShowFeedItemList() {
 }
 
 function setRssItemListBox() {
-	if(!rssObject) return;
+	if(!currentFeed) return;
 	if(document.getElementById("rssItemListBoxBox").hidden) return;
 
-	while(rssItemListBox.getRowCount() != 0){
+	while(rssItemListBox.getRowCount() != 0) {
 		rssItemListBox.removeItemAt(0);
 	}
 
-	for(var i=0; rssObject.items.length>i; i++){
-		var rssItem = rssObject.items[i];
-		var itemLabel = rssItem.title ? htmlToText(rssItem.title) : "No Title";
+	for(var i = 0; currentFeed.getItemCount() > i; i++) {
+		var item = currentFeed.getItem(i);
+		var itemLabel = item.getTitle();
 		itemLabel = (i+1) + ". " + itemLabel;
 		var listItem = rssItemListBox.appendItem(itemLabel, i);
 		
-		if(isVisited(rssItem.link)){
+		if(isVisited(item.getLink())) {
 			listItem.setAttribute("visited", "true");
-		}		
+		}
 	}
 }
 
@@ -519,8 +341,7 @@ function showRssItemListPopup(aEvent){
 		return;
 	}
 	
-	var description = rssObject.items[aEvent.originalTarget.value].description;
-		// �܂�Ԃ����邽�߂� URL�� / �̑O�Ƀ[�����X�y�[�X��lj�
+	var description = htmlToText(currentFeed.getItem(aEvent.originalTarget.value).getContent());
 	if(description.indexOf("/") != -1){
 		description = description.replace(/\//gm, "/\u200B");
 	}
@@ -567,10 +388,11 @@ function htmlToText(aStr){
 }
 
 
- // ++++++++++ +++++++++  HTTP	++++++++++ +++++++++ 
 
-function httpGet(aURL){
-	if(rssLoading){
+// ++++++++++ +++++++++  HTTP	++++++++++ +++++++++ 
+
+function httpGet(aURL) {
+	if(rssLoading) {
 		httpReq.abort();
 		rssLoading = false;
 	}
@@ -583,42 +405,43 @@ function httpGet(aURL){
 	httpReq.onreadystatechange = httpReadyStateChange;
 
 
-	try{
+	try {
 		httpReq.open("GET" , aURL);
 		httpReq.setRequestHeader("User-Agent", USER_AGENT);
 		httpReq.overrideMimeType("application/xml");
-	}catch(e){
+	} catch(e) {
 		httpGetResult(RESULT_ERROR_FAILURE);
 	}
 
-	try{
+	try {
 		httpReq.send(null);
 		rssLoading = true;
-	}catch(e){
+	} catch(e) {
 		httpGetResult(RESULT_ERROR_FAILURE);
 	}
 }
 
-function httpError(e){}
-function httpReadyStateChange(){
+function httpError(e) {}
 
-	if(httpReq.readyState == 2){
-		try{
-			if(httpReq.status == 404){
+function httpReadyStateChange() {
+
+	if(httpReq.readyState == 2) {
+		try {
+			if(httpReq.status == 404) {
 				httpGetResult(RESULT_NOT_FOUND);
 			}
-		}catch(e){
+		} catch(e) {
 			httpGetResult(RESULT_NOT_AVAILABLE);
 			return;
 		}
-	}else if(httpReq.readyState == 3){}
+	} else if(httpReq.readyState == 3) {}
 }
 
-function httpLoaded(e){
+function httpLoaded(e) {
 	responseXML = httpReq.responseXML;
 	var rootNodeName = responseXML.documentElement.localName.toLowerCase();
 
-	switch(rootNodeName){
+	switch(rootNodeName) {
 		case "parsererror":
 			// XML Parse Error
 			httpGetResult(RESULT_PARSE_ERROR);
@@ -635,24 +458,24 @@ function httpLoaded(e){
 	}
 }
 
-function httpGetResult(aResultCode){
+function httpGetResult(aResultCode) {
 	httpReq.abort();
 	rssLoading = false;
 
-	if(aResultCode == RESULT_OK){
-		createRssObject();
+	if(aResultCode == RESULT_OK) {
+		currentFeed = new Feed(responseXML);
 
-		if(lastResource.res){
-			BMSVC.updateLastVisitedDate(rssObject.rssURL, rssObject.charSet);
+		if(lastResource.res) {
+			BMSVC.updateLastVisitedDate(lastResource.res, responseXML.characterSet);
 			CommonFunc.setBMDSProperty(lastResource.res, CommonFunc.BM_DESCRIPTION, CommonFunc.STATUS_NO_UPDATE);
 		}
 		setStatusDone();
 		setRssItemListBox();
 		
-		if(getCheckboxCheck("chkOpenHTML")){
-			CreateHTML.openHTML(rssObject);
+		if(getCheckboxCheck("chkOpenHTML")) {
+			CreateHTML.openHTML(currentFeed);
 		}
-	}else{
+	} else {
 		setStatusError(resultStrArray[aResultCode]);
 	}
 }
\ No newline at end of file
diff --git a/src/sage/content/sage.xul b/src/sage/content/sage.xul
index 0d5188b..f80a7c1 100755
--- a/src/sage/content/sage.xul
+++ b/src/sage/content/sage.xul
@@ -18,6 +18,7 @@
 <script type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/>
 
 <script type="application/x-javascript" src="chrome://sage/content/commonfunc.js"/>
+<script type="application/x-javascript" src="chrome://sage/content/feedlib.js"/>
 <script type="application/x-javascript" src="chrome://sage/content/sage.js"/>
 <script type="application/x-javascript" src="chrome://sage/content/updatechecker.js"/>
 <script type="application/x-javascript" src="chrome://sage/content/createhtml.js"/>
diff --git a/src/sage/locale/en-US/sage.dtd b/src/sage/locale/en-US/sage.dtd
index d6b3f9f..85fbc39 100755
--- a/src/sage/locale/en-US/sage.dtd
+++ b/src/sage/locale/en-US/sage.dtd
@@ -1,5 +1,5 @@
 <!ENTITY sage.label				"Sage">
-<!ENTITY sage.version				"1.0">
+<!ENTITY sage.version				"1.1">
 
 <!ENTITY sage.toolbarLabel			"Sage">
 <!ENTITY sage.sidebarTitle			"Sage">
diff --git a/src/sage/locale/ja-JP/sage.dtd b/src/sage/locale/ja-JP/sage.dtd
index 70eb3bc..507126a 100755
--- a/src/sage/locale/ja-JP/sage.dtd
+++ b/src/sage/locale/ja-JP/sage.dtd
@@ -1,5 +1,5 @@
 <!ENTITY sage.label			"RSS リーダパネル">
-<!ENTITY sage.version			"1.7">
+<!ENTITY sage.version			"1.1">
 
 <!ENTITY sage.toolbarLabel		"RSS リーダ">
 <!ENTITY sage.sidebarTitle		"RSS リーダ">

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/sage-extension.git



More information about the Pkg-mozext-commits mailing list