User:Yair rand/languagetabs.js

var langcontent=new Array var langtabbaredit=new Array function createlanguagetabs { var langtabbar=document.createElement('h2') document.getElementById('toc').style.display="none" var x var v=document.getElementById("bodyContent").getElementsByTagName('h2') var prelangtabbar for(i in v) { if(v[i].lastChild&&v[i].lastChild.innerHTML!=undefined) { if(!prelangtabbar){prelangtabbar=v[i].previousSibling} var w=v[i].lastChild.innerHTML var qq=""+w+" " langtabbar.innerHTML+=qq langcontent[w]=document.createElement('span') var z=v[i] langtabbaredit[w]=z.firstChild while(z.nextSibling&&z.nextSibling.nodeName!='H2'&&z.nextSibling.className!="printfooter") {langcontent[w].appendChild(z.nextSibling)} if(langcontent[w].lastChild.previousSibling.nodeName=="HR") {langcontent[w].removeChild(langcontent[w].lastChild.previousSibling)} z.style.display="none" } } document.getElementById('bodyContent').insertBefore(langcontent[currentlangtab],prelangtabbar.nextSibling) document.getElementById('bodyContent').insertBefore(langtabbar,prelangtabbar) langtabbar.insertBefore(langtabbaredit[currentlangtab],langtabbar.firstChild) }

function updatelangtab(c,d) { document.getElementById('bodyContent').replaceChild(langcontent[c],langcontent[currentlangtab]) d.parentNode.replaceChild(langtabbaredit[c],langtabbaredit[currentlangtab]) document.getElementById('langtab'+currentlangtab).style.color="grey" currentlangtab=c d.style.color="black" }

if(wgNamespaceNumber==0) {addOnloadHook(createlanguagetabs)}