another ad-hoc, adding table of contents
This commit is contained in:
57
index.html
57
index.html
@@ -25,10 +25,11 @@
|
|||||||
content:" ";
|
content:" ";
|
||||||
padding-right: 1.0em;
|
padding-right: 1.0em;
|
||||||
}
|
}
|
||||||
|
A:toc { text-decoration:none; color: #000000; }
|
||||||
|
A:visited { text-decoration:none; color: #000000; }
|
||||||
A:link { text-decoration:none; color: #000000; }
|
A:link { text-decoration:none; color: #000000; }
|
||||||
A:visited { text-decoration:none; color: #000000; }
|
A:visited { text-decoration:none; color: #000000; }
|
||||||
A.link:hover { text-decoration: underline; }
|
A.link:hover, A.link:focus, A.toc:hover, A.toc:focus { text-decoration: underline; }
|
||||||
A.link:focus { text-decoration: underline; }
|
|
||||||
#filter { width: 100%; }
|
#filter { width: 100%; }
|
||||||
#search { width: 100%; display: table; }
|
#search { width: 100%; display: table; }
|
||||||
.search_span { display: table-cell; text-align: center; vertical-align: middle;
|
.search_span { display: table-cell; text-align: center; vertical-align: middle;
|
||||||
@@ -147,9 +148,9 @@ function make_menu() {
|
|||||||
if (match != null) {
|
if (match != null) {
|
||||||
//if ( linkList[c].substring(0,2) == "# " ) {
|
//if ( linkList[c].substring(0,2) == "# " ) {
|
||||||
var opt=document.createElement("option");
|
var opt=document.createElement("option");
|
||||||
var name=match[2].trim().replace(/ /g,"");
|
var name=match.trim().replace(/ /g,"");
|
||||||
opt.innerHTML=linkList[c].trim();
|
opt.innerHTML=match.trim();
|
||||||
opt.value="anchor_" + name.replace(/^#/,"") + "_" + anchor_index;
|
opt.value="anchor_" + name + "_" + anchor_index;
|
||||||
sel.appendChild(opt);
|
sel.appendChild(opt);
|
||||||
anchor_index++;
|
anchor_index++;
|
||||||
}
|
}
|
||||||
@@ -225,6 +226,8 @@ function search_hits(needle) {
|
|||||||
function open_link(c) {
|
function open_link(c) {
|
||||||
var match=linkReg.exec(linkList[c]);
|
var match=linkReg.exec(linkList[c]);
|
||||||
if (match != null ) { location.href=match[3]; return }
|
if (match != null ) { location.href=match[3]; return }
|
||||||
|
match=dwLinkReg.exec(linkList[c]);
|
||||||
|
if (match != null ) { location.href=match[2]; return }
|
||||||
match=linkPlain.exec(linkList[c]);
|
match=linkPlain.exec(linkList[c]);
|
||||||
if (match != null ) { location.href=match[2]; return }
|
if (match != null ) { location.href=match[2]; return }
|
||||||
return
|
return
|
||||||
@@ -245,7 +248,7 @@ function print_results(hitList) {
|
|||||||
if (narrow_window()) { td.className+=" narrow"; }
|
if (narrow_window()) { td.className+=" narrow"; }
|
||||||
td.innerHTML+=make_head(linkList[c],cat);
|
td.innerHTML+=make_head(linkList[c],cat);
|
||||||
td.appendChild(td_content);
|
td.appendChild(td_content);
|
||||||
cats.push({name:name, td:td, count:0});
|
cats.push({name:name, td:td, count:0, original:match});
|
||||||
cat+=1;
|
cat+=1;
|
||||||
} else {
|
} else {
|
||||||
if (hitList.indexOf(c)==-1) { continue }
|
if (hitList.indexOf(c)==-1) { continue }
|
||||||
@@ -259,6 +262,45 @@ function print_results(hitList) {
|
|||||||
var tbody=document.createElement("tbody");
|
var tbody=document.createElement("tbody");
|
||||||
var tr=document.createElement("tr");
|
var tr=document.createElement("tr");
|
||||||
var print_cat=0;
|
var print_cat=0;
|
||||||
|
if (config.toc !== null) {
|
||||||
|
var tr=document.createElement("tr");
|
||||||
|
tbody.appendChild(tr);
|
||||||
|
var td=document.createElement("td");
|
||||||
|
td.id="td_"+config.toc.replace(/ /g,"")+"_0";
|
||||||
|
td.innerHTML+=make_head("# "+config.toc,0);
|
||||||
|
tr.appendChild(td);
|
||||||
|
var td_content = document.createElement("div");
|
||||||
|
td_content.id="content_"+config.toc.replace(/ /g,"")+"_0";
|
||||||
|
if (narrow_window()) { td.className+=" narrow"; }
|
||||||
|
td.appendChild(td_content);
|
||||||
|
for (cat=0; cat<cats.length; cat++) {
|
||||||
|
if (cats[cat].count>0) {
|
||||||
|
var li=document.createElement("li");
|
||||||
|
var a=document.createElement("a");
|
||||||
|
a.className += "toc";
|
||||||
|
var name = cats[cat].name.replace(/ /g,"")+"_"+cat;
|
||||||
|
a.href="#anchor_"+name;
|
||||||
|
a.data=name;
|
||||||
|
a.innerHTML = cats[cat].original;
|
||||||
|
a.onclick=function(){
|
||||||
|
var head="head_" + this.data;
|
||||||
|
document.getElementById(head).classList.add("blink");
|
||||||
|
fold_set(this.data,false);
|
||||||
|
setTimeout(function(){ document.getElementById(head).classList.remove("blink"); }, 3000);
|
||||||
|
document.getElementById("anchor_" + this.data).scrollIntoView({ behavior: 'smooth' });
|
||||||
|
};
|
||||||
|
a.ontouchstart = a.onclick;
|
||||||
|
li.appendChild(a);
|
||||||
|
td_content.appendChild(li);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print_cat = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
for (cat=0; cat<cats.length; cat++) {
|
for (cat=0; cat<cats.length; cat++) {
|
||||||
if (cats[cat].count>0) {
|
if (cats[cat].count>0) {
|
||||||
if ((print_cat%config.columns==0 || narrow_window())) {
|
if ((print_cat%config.columns==0 || narrow_window())) {
|
||||||
@@ -523,7 +565,8 @@ var config = {
|
|||||||
favicon:null, // link to favicon file
|
favicon:null, // link to favicon file
|
||||||
narrow:600, // pixel width that is narrow screen = single column table
|
narrow:600, // pixel width that is narrow screen = single column table
|
||||||
arrows:['📙','📚'], // Arrow characters for in/out tab icon
|
arrows:['📙','📚'], // Arrow characters for in/out tab icon
|
||||||
foldCategories:true // fold categories in single column mode
|
foldCategories:true, // fold categories in single column mode
|
||||||
|
toc: null // Title of TableOfContents, if null, no TOC
|
||||||
};
|
};
|
||||||
// TEMPLATED:CONFIG
|
// TEMPLATED:CONFIG
|
||||||
// TEMPLATED:LINKS
|
// TEMPLATED:LINKS
|
||||||
|
|||||||
Reference in New Issue
Block a user