summaryrefslogtreecommitdiffstats
path: root/genman.txr
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-12-12 21:53:22 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-12-12 21:53:22 -0800
commitc5eef019eac0ddb24959ace7459b492b8fb3af3b (patch)
tree6328f8dc7097041383ae93dd16f0dbecfdc98749 /genman.txr
parent2e2516e181bb4ffbbe516a85ec9d672faa344f79 (diff)
downloadtxr-c5eef019eac0ddb24959ace7459b492b8fb3af3b.tar.gz
txr-c5eef019eac0ddb24959ace7459b492b8fb3af3b.tar.bz2
txr-c5eef019eac0ddb24959ace7459b492b8fb3af3b.zip
HTML doc: expand TOC section on jumpback.
When a section number is clicked, if the table of contents section which contains it is collapsed, open it, and its parents. * genman.txr: (tocjump): New JS function. add onclick action to jump-back links, which calls tocjump JS function which does the expansion. The name anchor entries in the TOC are tagged with a "tocanchor: class so they can be more specifically selected by the tocjump function.
Diffstat (limited to 'genman.txr')
-rw-r--r--genman.txr23
1 files changed, 21 insertions, 2 deletions
diff --git a/genman.txr b/genman.txr
index c81e18c0..89a96fb9 100644
--- a/genman.txr
+++ b/genman.txr
@@ -52,7 +52,7 @@ Content-type: text/html
@ (do (set [tagmap tag] newtag))
@ (output :into BODY)
<A NAME="@newtag">&nbsp;</A>
-<H@level><A HREF="#@(toc-tag sec)">@sec</A> @title</H@level>
+<H@level><A HREF="#@(toc-tag sec)" ONCLICK="tocjump('@(toc-tag sec)')">@sec</A> @title</H@level>
@ (end)
@ (cat BODY "\n")
@ (or)
@@ -75,7 +75,7 @@ Content-type: text/html
@ (some)
@ (cases)
<DT><A HREF="#@tag">@num @rest
-@ (bind TOC `<DT><A NAME="@(toc-tag num)">@num</A> <A HREF="#@[tagmap tag]">@rest`)
+@ (bind TOC `<DT><A NAME="@(toc-tag num)" CLASS="tocanchor">@num</A> <A HREF="#@[tagmap tag]">@rest`)
@ (or)
<A NAME="index">@(skip)
@ (output :into TOC)
@@ -180,6 +180,25 @@ function toggleall(link) {
link.innerHTML = (disp == '') ? '@xpnall' : '@clpsall';
}
+function tocjump(hash) {
+ var toc = document.getElementsByClassName("TOC");
+ var tanch = toc[0].getElementsByClassName("tocanchor");
+
+ for (var i = 0; i < tanch.length; i++) {
+ var ta = tanch[i];
+
+ if (ta.name == hash) {
+ for (var e = ta.parentNode; e !== null; e = e.parentElement) {
+ if (e.tagName == "DL") {
+ var atoggles = e.getElementsByClassName("toggle");
+ e.style.display = '';
+ if (atoggles.length > 0)
+ atoggles[0].innerHTML = '@opentxt';
+ }
+ }
+ }
+ }
+}
</script>
</HEAD><BODY>
<H2>Manpage for <A HREF="#@[tagmap "lbAB"]">TXR </a>@VERSION</H2>