forked from Mirrors/freeswitch
86 lines
2.4 KiB
Plaintext
Executable File
86 lines
2.4 KiB
Plaintext
Executable File
ifdef::backend-xhtml11[]
|
|
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
<div id="toc"></div>
|
|
<script>
|
|
window.onload=generate_TOC
|
|
|
|
/* Author: Mihai Bazon, September 2002
|
|
* http://students.infoiasi.ro/~mishoo
|
|
*
|
|
* Table Of Content generator
|
|
* Version: 0.4
|
|
*
|
|
* Feel free to use this script under the terms of the GNU General Public
|
|
* License, as long as you do not remove or alter this notice.
|
|
*/
|
|
|
|
/* modified by Troy D. Hanson, September 2006. License: GPL */
|
|
|
|
function H_getText(el) {
|
|
var text = "";
|
|
for (var i = el.firstChild; i != null; i = i.nextSibling) {
|
|
if (i.nodeType == 3 /* Node.TEXT_NODE, IE doesn't speak constants */)
|
|
text += i.data;
|
|
else if (i.firstChild != null)
|
|
text += H_getText(i);
|
|
}
|
|
return text;
|
|
}
|
|
|
|
function TOC_EL(el, text, level) {
|
|
this.element = el;
|
|
this.text = text;
|
|
this.level = level;
|
|
}
|
|
|
|
function getHeadlines(el) {
|
|
var l = new Array;
|
|
var rx = /[hH]([2-3])/;
|
|
// internal recursive function that scans the DOM tree
|
|
var rec = function (el) {
|
|
for (var i = el.firstChild; i != null; i = i.nextSibling) {
|
|
if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
|
|
if (rx.exec(i.tagName))
|
|
l[l.length] = new TOC_EL(i, H_getText(i), parseInt(RegExp.$1));
|
|
rec(i);
|
|
}
|
|
}
|
|
}
|
|
rec(el);
|
|
return l;
|
|
}
|
|
|
|
function generate_TOC() {
|
|
var parent = document.getElementById("toc");
|
|
var toc_hdr = document.createElement("div");
|
|
var toc_hdr_txt = document.createTextNode("CONTENTS");
|
|
toc_hdr.appendChild(toc_hdr_txt);
|
|
/* toc_hdr.setAttribute("id","hdr"); */
|
|
toc_hdr.id = "hdr";
|
|
parent.appendChild(toc_hdr);
|
|
var hs = getHeadlines(document.getElementsByTagName("body")[0]);
|
|
for (var i = 0; i < hs.length; ++i) {
|
|
var hi = hs[i];
|
|
var d = document.createElement("div");
|
|
if (hi.element.id == "") hi.element.id = "gen" + i;
|
|
var a = document.createElement("a");
|
|
a.href = "#" + hi.element.id;
|
|
a.appendChild(document.createTextNode(hi.text));
|
|
d.appendChild(a);
|
|
d.className = "level" + hi.level;
|
|
parent.appendChild(d);
|
|
/*
|
|
if (hi.level == 3) {
|
|
var dvtop = document.createElement("div");
|
|
dvtop.className = "toplink";
|
|
dvtop.appendChild(document.createTextNode("^top^"));
|
|
dvtop.onclick=function(){scrollTo(0,0);};
|
|
hi.element.appendChild(dvtop);
|
|
}
|
|
*/
|
|
}
|
|
}
|
|
</script>
|
|
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
endif::backend-xhtml11[]
|