|
|
Line 20: |
Line 20: |
| cursor:pointer; | | cursor:pointer; |
| } | | } |
| + | |
| #innertoc{ | | #innertoc{ |
| } | | } |
Line 69: |
Line 70: |
| } | | } |
| | | |
- | function createTOC() {
| |
- | var y = document.createElement('div');
| |
- | IE = /*@cc_on!@*/false;
| |
- | if(IE==true){return y;}
| |
- | y.id = 'innertoc';
| |
- | var a = document.createElement('a');
| |
- | a.innerHTML="<b>Page Content -</b>";
| |
- | a.id = 'contentheader';
| |
- | a.onclick = showhideTOC;
| |
- | y.appendChild(a);
| |
- | var z = y.appendChild(document.createElement('div'));
| |
- | z.id='tocDIV';
| |
- | var bodycon = document.getElementById('Main');
| |
- | var toBeTOCced = getElementsByTagNames('h2,h3,h4,h5',bodycon);
| |
- | if (toBeTOCced.length < 2) return false;
| |
- |
| |
- | for (var i=0;i<toBeTOCced.length;i++) {
| |
- | var tmp = document.createElement('a');
| |
- | var temp = toBeTOCced[i];
| |
- | var MW = temp.getElementsByClassName('mw-headline');
| |
- | if(!MW){MW = temp.getElementsByTagName('span');}
| |
- | var B = MW[0].getElementsByTagName('b');
| |
- | var result;
| |
- | if(B.length==0){
| |
- | result = MW[0].innerHTML;
| |
- | }
| |
- | else{result = B[0].innerHTML;}
| |
- | //alert(result);
| |
- | tmp.innerHTML = result;
| |
- | tmp.className = 'page';
| |
- | z.appendChild(tmp);
| |
- | z.appendChild(document.createElement('br'));
| |
- | if (toBeTOCced[i].nodeName == 'H2'){
| |
- | tmp.style.color="black";
| |
- | tmp.innerHTML="<b>"+tmp.innerHTML+"<\/b>"
| |
- | }
| |
- | if (toBeTOCced[i].nodeName == 'H3'){
| |
- | tmp.className += ' indent';
| |
- | tmp.style.color="black";
| |
- | }
| |
- | if (toBeTOCced[i].nodeName == 'H4'){
| |
- | tmp.className += ' extraindent';
| |
- | tmp.style.color="grey";
| |
- | }
| |
- | if (toBeTOCced[i].nodeName == 'H5'){
| |
- | tmp.className += ' extraextraindent';
| |
- | }
| |
- | var headerId = result;
| |
- | tmp.href = '#' + headerId;
| |
- | toBeTOCced[i].id = headerId;
| |
- | }
| |
- | return y;
| |
- | }
| |
| | | |
| var TOCstate = 'block'; | | var TOCstate = 'block'; |
- |
| |
- | function showhideTOC() {
| |
- | TOCstate = (TOCstate == 'none') ? 'block' : 'none';
| |
- | var newText = (TOCstate == 'none') ? 'Page Content +' : 'Page Content -';
| |
- | document.getElementById('contentheader').innerHTML = '<strong>'+newText+'</strong>';
| |
- | document.getElementById('innertoc').lastChild.style.display = TOCstate;
| |
- | }
| |
| | | |
| </script> | | </script> |