MediaWiki:Bluecloud.js

// ============================================================ // BEGIN DOM Table of Contents Sidebar (experimantal)

// Creates the Article Tags group header in #nav_right // Adds div.articletag elements to above group // Appends any div.nav_toc_append to #nav_right // Moves any existing #nav_toc to #nav_right function domNavToc {	//var errNode = document.createTextNode( "No Sidebar" ); var navRight = document.getElementById( 'nav_right' );

if( !navRight ) { return 0; }	// Append all .nav_toc classed elements under #nav_toc_append var len; var articleTags; var navTocElements; var bodyContent = document.getElementById('bodyContent'); if(document.getElementsBySelector) { articleTags = document.getElementsBySelector('#bodyContent div.articletag'); navTocElements = document.getElementsBySelector('#bodyContent div.nav_toc_append'); }	else if(bodyContent && getElementsByClassName) { articleTags = getElementsByClassName(bodyContent,'div','articletag'); navTocElements = getElementsByClassName(bodyContent,'div','nav_toc_append'); }	else { return 0; }

var hasArticleTags = articleTags.length > 0; if (hasArticleTags) {		navRight.innerHTML += ' Article Tags ' var articleTagBox = document.getElementById('articletags'); }

len = navTocElements.length; for(var i = 0; i < len; i++) {		var navTocAppend = navTocElements[i]; if( navTocAppend ) { var navTocAppendClone = navTocAppend.cloneNode(true); var oRegExp = new RegExp("(^|\\s)" + "articletag" + "(\\s|$)"); if(hasArticleTags && oRegExp.test(navTocAppend.className)) { articleTagBox.appendChild(navTocAppendClone); }			else { navRight.appendChild(navTocAppendClone); }			//not the right way to do this if(navTocAppendClone.style.display) {thisNavTocClone.style.display = 'block';} if(navTocAppendClone.visibility) {thisNavTocClone.visibility = 'visible';} navTocAppend.parentNode.removeChild(navTocAppend); }	}

// Append errNode if navToc doesn't exist var navToc  = document.getElementById( 'nav_toc' ); if( !navToc ) { //navRight.appendChild( errNode ); return 0; }

var navToc2 = navToc.cloneNode(true); navToc.parentNode.removeChild(navToc); navRight.appendChild( navToc2 );

navToc2.style.display = 'block'; }

// END DOM Table of Contents Sidebar // ============================================================