User:Pasixxxx/monobook.js

//Inserts links that points to toc

var GlobDoc; function scr { var dest=GlobDoc.getElementById("toc"); dest.scrollIntoView;

} function MyHtmlFrag(doc) {	var sm,txt,a,sp;

//this.ce=doc.createElement("center"); //sm=doc.createElement("small"); txt=doc.createTextNode("contents"); this.sp=doc.createElement("span"); a=doc.createElement("a"); a.setAttribute("href","#toc"); //a.onclick=scr; this.sp.setAttribute("class","editsection");

a.appendChild(txt); //sm.appendChild(a); //this.ce.appendChild(sm); //this.ce.appendChild(a); //return this.ce; this.sp.appendChild(doc.createTextNode("[")); this.sp.appendChild(a); this.sp.appendChild(doc.createTextNode("]")); return this.sp; }

function insertLinks(tg,doc) {	var el,coll; var i; var content;

coll=doc.getElementsByTagName(tg); for(i=0;iContents'; //content=el.innerHtml+" test"; //el.innerHtml=content; //el.insertBefore(new MyHtmlFrag(doc),el.lastChild); el.appendChild(new MyHtmlFrag(doc));

} }

function insertLinksToTOC {	var doc=this.document; GlobDoc=doc; if(doc.getElementById("toc")==undefined) return;

insertLinks("h2",doc); insertLinks("h3",doc); insertLinks("h4",doc); }

addOnloadHook(

function { insertLinksToTOC; }

);

/* $(function { elems = document.getElementsByClassName('editsection'); var target="#top"; if(!(document.getElementById("toc")==undefined)) target="#toc";	for (i = 0; i <  elems.length; i++)  elems[i].innerHTML = '[Back to '+target+'] ' + elems[i].innerHTML; });