StoriesIndex.prototype.attachLatestWheelsBlogs = function(oP) { if(!this.searchStories || this.searchStories.length == 0)return; oP.className = 'blogs'; var oTableBody = document.createElement('tbody'); var max = 5; if(this.searchStories.length < 5)max = this.searchStories.length; for(var i = 0; i < max; i++) { this.searchStories[i].attachLatestWheelsBlogs(oTableBody,i+1); } var oTable = document.createElement('table'); oTable.appendChild(oTableBody); oP.appendChild(oTable); }; ArticleSearchObject.prototype.attachLatestWheelsBlogs = function(oTag,i) { var comments = getComments(this.viewDocID); var oTR = document.createElement('tr'); var oTD = document.createElement('td'); var oAnchor = document.createElement('a'); oAnchor.title = unescape(this.viewTitle); oAnchor.setAttribute('href','/wheels/site/articleIDs/' + this.viewDocID + '?open&template=domWheels'); oAnchor.appendChild(document.createTextNode(unescape(this.viewTitle))); oTD.appendChild(oAnchor); oTR.appendChild(oTD); var oTD = document.createElement('td'); oTD.appendChild(document.createTextNode(comments)); oTR.appendChild(oTD); oTag.appendChild(oTR); }; StoriesIndex.prototype.attachLatestWheelsAdditions = function(oP) { if(!this.searchStories || this.searchStories.length == 0)return; oP.className = 'additions'; var max = 5; if(this.searchStories.length < 5)max = this.searchStories.length; for(var i = 0; i < max; i++) { this.searchStories[i].attachLatestWheelsAdditions(oP,i+1); } }; ArticleSearchObject.prototype.attachLatestWheelsAdditions = function(oTag,i) { var oAnchor = document.createElement('a'); oAnchor.setAttribute('href','/wheels/site/articleIDs/' + this.viewDocID + '?open&template=domWheels'); oAnchor.title = unescape(this.viewTitle); oAnchor.appendChild(document.createTextNode(unescape(this.viewTitle))); oTag.appendChild(oAnchor); }; function getComments(id) { var thisXMLurl = "/wheels/tools/filter.js?readform&type=Talkback&cat=" + id +"&start=1&count=1000"; loadXMLDoc(thisXMLurl); if (tbResults[1].tbDocID != "") { return tbResults.length-1; } else { return 0; } // return tbResults.length; } var xmlhttp; function loadXMLDoc(url) { // code for IE if (window.ActiveXObject) { xmlhttp=new ActiveXObject("Microsoft.xmlhttp") if (xmlhttp) { xmlhttp.onreadystatechange= function () { if (xmlhttp.readyState==4) { // if "OK" if (xmlhttp.status==200) { eval(xmlhttp.responseText); } else { alert("Problem retrieving XML data:" + xmlhttp.statusText) } } } xmlhttp.open("GET",url,false) xmlhttp.send() } } else if (window.XMLHttpRequest) {// code for Mozilla, etc. xmlhttp=new XMLHttpRequest() //xmlhttp.onreadystatechange=state_Change xmlhttp.onload = function () { eval(xmlhttp.responseText); } xmlhttp.open("GET",url,false) xmlhttp.send(null) } } function changeTab(oEvent) { latestWheels.changeTab(oEvent); } function LatestWheels() { if(typeof LatestWheels._initialized == 'undefined') { LatestWheels.prototype.load = function() { this.loadComments(); this.loadBlogs(); this.loadAdditions(); }; LatestWheels.prototype.loadComments = function() { this.mostRecentComments = new MostRecentComments(); this.mostRecentComments.load('mostRecentComments'); }; LatestWheels.prototype.loadBlogs = function() { this.latestBlogs = new StoriesIndex(); var searchQuery = '((([PageType]=article)+or+([PageType]=related))+and+([SectionPath]=Blogs))'; this.latestBlogs.addSearch(searchQuery,'1','9','3','latestBlogs'); this.latestBlogs.loadSearch(); }; LatestWheels.prototype.loadAdditions = function() { this.latestAdditions = new StoriesIndex(); var searchQuery = '([PageType]=article)'; this.latestAdditions.addSearch(searchQuery,'1','9','3','latestAdditions'); this.latestAdditions.loadSearch(); }; LatestWheels.prototype.attach = function(obj) { this.attachHeading(); this.attachNav(obj); this.attachParagraph(); this.attachMoreLink(); }; LatestWheels.prototype.attachHeading = function() { switch(this.getCurrent()) { case 'comments': case 'blogs': var latestWheels = document.getElementById('latestWheels'); var oH = document.createElement('h3'); oH.appendChild(document.createTextNode('Latest Wheels')); latestWheels.appendChild(oH); break; default: } }; LatestWheels.prototype.attachNav = function(obj) { var latestWheels = document.getElementById('latestWheels'); if(latestWheels.getElementsByTagName('div').length == 0) { latestWheels.appendChild(document.createElement('div')); } else { latestWheels.getElementsByTagName('div')[0].innerHTML = ""; } switch(this.getCurrent()) { case 'blogs': this.attachNavItem('blogs',obj,'current'); this.attachNavItem('additions',obj); this.attachNavItem('comments',obj); break; case 'additions': this.attachNavItem('blogs',obj); this.attachNavItem('additions',obj,'current'); this.attachNavItem('comments',obj); break; case 'comments': this.attachNavItem('blogs',obj); this.attachNavItem('additions',obj); this.attachNavItem('comments',obj,'current'); break; default: } }; LatestWheels.prototype.attachParagraph = function() { var latestWheels = document.getElementById('latestWheels'); if(latestWheels.getElementsByTagName('p').length == 0) { latestWheels.appendChild(document.createElement('p')); } else { latestWheels.getElementsByTagName('p')[0].innerHTML = ""; } switch(this.getCurrent()) { case 'blogs': var oP = latestWheels.getElementsByTagName('p')[0]; this.latestBlogs.attachLatestWheelsBlogs(oP); break; case 'additions': var oP = latestWheels.getElementsByTagName('p')[0]; this.latestAdditions.attachLatestWheelsAdditions(oP); break; case 'comments': var oP = latestWheels.getElementsByTagName('p')[0]; this.mostRecentComments.attach(oP); break; default: } }; LatestWheels.prototype.attachMoreLink = function() { switch(this.getCurrent()) { case 'blogs': var sLink = '/wheels/site/index?open&type=Sections&cat=Blogs&start=1&count=20'; break; //case 'additions': //var sLink = '/wheels/site/index?open&type=Search&query=([PageType]=article)&start=1&count=20&SearchOrder=3&label=Latest+additions'; //break; default: } switch(this.getCurrent()) { case 'blogs': //case 'additions': var oP = document.getElementById('latestWheels').getElementsByTagName('p')[0]; var oSpan = document.createElement('span'); oSpan.className = 'more'; var oAnchor = document.createElement('a'); oAnchor.setAttribute('href',sLink); oAnchor.appendChild(document.createTextNode('More >>')); oSpan.appendChild(oAnchor); oP.appendChild(oSpan); break; default: } }; LatestWheels.prototype.attachNavItem = function(navItem,obj,current) { var oDiv = document.getElementById('latestWheels').getElementsByTagName('div')[0]; var oAnchor = document.createElement('a') if(current)oAnchor.className = 'current'; oAnchor.title = navItem; oAnchor.setAttribute('href','#'); if(document.attachEvent) { //oAnchor.onclick = obj + '.changeTab(event)'; oAnchor.onclick = function(event){changeTab(event)}; } else { oAnchor.setAttribute('onclick',obj + '.changeTab(event)'); } var oSpan = document.createElement('span'); if(document.attachEvent) { oSpan.onmouseover = function(){this.style.cursor = 'pointer';} } oSpan.appendChild(document.createTextNode(navItem)); oAnchor.appendChild(oSpan); oDiv.appendChild(oAnchor); }; LatestWheels.prototype.changeTab = function(oEvent) { var target = stopEvent(oEvent); var title = target.parentNode.title; this.current = title; this.attachNav('latestWheels'); this.attachParagraph(); this.attachMoreLink(); }; LatestWheels.prototype.getCurrent = function() { if(this.current)return this.current; if(this.latestBlogs.searchStories && this.latestBlogs.searchStories.length > 0)return 'blogs'; if(this.latestAdditions.searchStories && this.latestAdditions.searchStories.length > 0)return 'additions'; if(this.mostRecentComments && this.mostRecentComments.loaded())return 'comments'; return 'undefined'; }; } LatestWheels._initialized = true; } var latestWheels = new LatestWheels(); latestWheels.load(); latestWheels.attach('latestWheels');