rendered paste bodyfunction Tab(url) {
this.url = url;
this.loadstatus = "loading";
var xhr = new XMLHttpRequest();
var self = this;
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
self.content = "";
self.longtitle = xhr.responseXML.getElementsByTagName("title")[0].firstChild.nodeValue;
if (self.longtitle.length >= 14) {
self.shorttitle = self.longtitle.substr(0, 10);
if (self.shorttitle.substr(self.shorttitle.length - 1, 1) == " ") {
self.shorttitle = self.shorttitle.substr(0, self.shorttitle.length - 1);
}
self.shorttitle += "
";
} else {
self.shorttitle = self.longtitle;
}
self.tabcode = '<div class="newtab">';
self.tabcode += '<div class="tableft"></div>';
self.tabcode += '<span class="tabmiddle"><span class="label" title="' + self.longtitle + '">' + self.shorttitle + '</span></span>';
self.tabcode += '<div class="tabright"></div></div>';
var articles = new Array();
articles = xhr.responseXML.getElementsByTagName("item");
var arDiv;
var selfTab = new Tab(xhr.responseXML.getElementsByTagName("title")[0].firstChild.nodeValue);
var parsedArticles = new Array();
for (i = 0; i < articles.length; i++) {
// create the div for the entire article
arDiv = document.createElement("div");
arDiv.id = "article" + i;
arDiv.className = "article";
// create the div for the title
arTiDiv = document.createElement("div");
arTiDiv.id = "arTitle" + i;
arTiDiv.className = "arTitle";
arTiDiv.innerHTML = '<a href="#" onclick="widget.openURL(' + "'" + articles[i].getElementsByTagName("link")[0].firstChild.nodeValue + "'" + ');">' + articles[i].getElementsByTagName("title")[0].firstChild.nodeValue + '</a>';
arDiv.appendChild(arTiDiv);
// create the div for the date
arDate = document.createElement("div");
arDate.id = "arDate" + i;
arDate.className = "arDate";
arDate.innerHTML = "(" + articles[i].getElementsByTagName("pubDate")[0].firstChild.nodeValue + ")";
arDiv.appendChild(arDate);
// create the div for the body
arBodyDiv = document.createElement("div");
arBodyDiv.id = "arBody" + i;
arBodyDiv.className = "arBody";
arBodyDiv.innerHTML = truncate(articles[i].getElementsByTagName("description")[0].firstChild.nodeValue, truncAmount);
arDiv.appendChild(arBodyDiv);
parsedArticles[i] = arDiv;
}
// remove unnecessary padding
parsedArticles[parsedArticles.length - 1].style.padding = "0px";
for (i in parsedArticles) {
self.content += parsedArticles[i].outerHTML;
}
self.loadstatus = "done";
reloadTabs();
}
};
xhr.open("GET", this.url, true);
xhr.send(null);
}