[Pmwiki-users] Abt toc

Reimer Behrends behrends
Wed Dec 3 04:07:07 CST 2003

On Wed, Dec 03, 2003 at 08:34:13AM +1300, John Rankin wrote:
[Hide/Show Button for TOC.]
> Yes and I was rather hoping that you wouldn't...
> Please may I invoke PmWiki's "Avoid gratuitous features" principle.
> I should have workable auto contents code in the next day or so.

It's actually fairly easy to do it in Javascript. See below for an
example, most of which should be easy to plug in once the basic
functionality exists (basically, you just insert the two <script>
parts and the <div> surrounding the part that needs to be toggled).

			Reimer Behrends

  <title>TOC Example</title> 
  <script type="text/javascript"><!--
  function tocToggleVisibility()
    try {
      var toc = document.getElementById("toclist");
      var tochide = document.getElementById("tochide");
      var tocshow = document.getElementById("tocshow");
      if (toc.style.display != "none")
	toc.style.display = "none";
	tochide.style.display = "none";
	tocshow.style.display = "inline";
	toc.style.display = "block";
	tochide.style.display = "inline";
	tocshow.style.display = "none";
    } catch(e) { }
  <table border=1> <tr> <td>
    Table of Contents
    <script type="text/javascript"><!--
      if (document.getElementById)
        document.write("<a href='javascript:tocToggleVisibility()'>");
        document.write("<span id=tochide>(hide)</span>");
	document.write("<span style='display:none' id=tocshow>(show)</span>");
    <div id=toclist>
      <li>Item 1.
	<li>Subitem 1.1
	<li>Subitem 1.2
      <li>Item 2
  </div> <!-- end of #toclist -->
  </td> </tr> </table>

More information about the pmwiki-users mailing list