Make your own free website on Tripod.com

In progress archive script to alternate between showing four links and showing all links.
Test blog is at testitout3.blogspot.com.

// My Type 'ArchivePage'
function ArchivePage( theLink, theName )
{ this.Link = theLink; this.Name = theName; }

// Write links
function WriteLinks( first, last, show ){
 // check for adequate DOM support
 if (!document.getElementById || !document.createElement) return;
 theSpan = document.getElementById("archivespan");
 // set theSpan invisible
 theSpan.style.display = "none";
 // kill theSpan's children
 while(theSpan.hasChildNodes())
  {theSpan.removeChild(theSpan.childNodes[0]);}
 // create a current link if in an archive page
 //## N.B. Below replace "archive" with the basename of 
 //## your archive files
 if ( -1 != location.href.indexOf( "archive" ) ){
  linkNode=document.createElement("a");    
  linkNode.setAttribute("href", "<$BlogURL$>");
  linkText=document.createTextNode("current");
  linkNode.appendChild(linkText);
  theSpan.appendChild(linkNode);
  brNode=document.createElement("br");
  theSpan.appendChild(brNode);
  }
 // create the link children and attach
 for (var n=last; n>first; n--){
  linkNode=document.createElement("a");
  linkNode.setAttribute("href", BlogInfo[n-1].Link);
  linkText=document.createTextNode(BlogInfo[n-1].Name);
  linkNode.appendChild(linkText);
  theSpan.appendChild(linkNode);
  brNode=document.createElement("br");
  theSpan.appendChild(brNode);
  }
 // create the show child and attach
 linkNode=document.createElement("a");
 if (show == "all"){
  linkNode.setAttribute("href", "javascript:void(WriteLinks(BlogInfo.length-limit,BlogInfo.length,'some'))");
  linkText=document.createTextNode("Show less");
  }
 else {
  linkNode.setAttribute("href", "javascript:void(WriteLinks('1',BlogInfo.length,'all'))");
  linkText=document.createTextNode("Show all");
  }
 linkNode.appendChild(linkText);
 theSpan.appendChild(linkNode);
 // set theSpan visible
 theSpan.style.display = "inline";
 }

// Blogger Populates Data here
var count=0;
var BlogInfo = new Array();
<Blogger>
BlogInfo[count++] = new ArchivePage( "<$BlogArchiveLink$>" , "<$BlogArchiveName$>" );
</Blogger>

// Process & Output Archive Links 

//## Set your limit here ##
var limit=4;
if ( limit > BlogInfo.length ) limit = BlogInfo.length;
// The Archives
document.write("<span id='archivespan'></span>");
WriteLinks(BlogInfo.length-limit, BlogInfo.length, "some");

To do: