From c5eef019eac0ddb24959ace7459b492b8fb3af3b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 12 Dec 2015 21:53:22 -0800 Subject: 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. --- genman.txr | 23 +++++++++++++++++++++-- 1 file 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)   -@sec @title +@sec @title @ (end) @ (cat BODY "\n") @ (or) @@ -75,7 +75,7 @@ Content-type: text/html @ (some) @ (cases)
@num @rest -@ (bind TOC `
@num @rest`) +@ (bind TOC `
@num @rest`) @ (or) @(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'; + } + } + } + } +}

Manpage for TXR @VERSION

-- cgit v1.2.3