Jump to content

User:Virgolette/vector.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Virgolette (talk | contribs) at 16:22, 16 May 2010 (test). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
addOnloadHook(function(){
	//If I knew jQuery, this would be so much easier:
	if (typeof(VectorMenuToTabs)=="undefined") VectorMenuToTabs = {ids: ["p-cactions"]};
 
	for (var j=0; j<VectorMenuToTabs.ids.length; j++)
	{
		root = document.getElementById( VectorMenuToTabs.ids[j] );
		if (!root) return;
 
		var innerDiv = root.getElementsByTagName( 'div' )[0];
		if (!innerDiv) return;
 
		var ul = innerDiv.children[0];
		if (!ul || ul.tagName!="UL") return;
 
		for (var i=0; i<ul.children.length; i++)
		{
			var li = ul.children[i];
			if (!li || li.tagName!="LI" || li.children.length<1) continue;
			var a = li.children[0];
			if (!a || a.tagName!="A" || a.childNodes.length!=1 || a.childNodes[0].nodeType!=3) continue;
 
			var span = document.createElement("span");
			var text = a.childNodes[0];
			a.removeChild(text);
			span.appendChild(text);
			a.appendChild(span);
		}
 
		root.className = root.className.replace( /(^| )vectorMenu( |$)/, "$1vectorTabs$2" );
		root.appendChild(ul);
		root.removeChild(innerDiv);
	}
});