[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



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN">
<html>
<head>
  <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";
      }
      else
      {
	toc.style.display = "block";
	tochide.style.display = "inline";
	tocshow.style.display = "none";
      }
    } catch(e) { }
  }
  --></script>
</head>
<body>
  <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>");
        document.write("</a>");
      }
    --></script>
    <div id=toclist>
    <ol>
      <li>Item 1.
      <ol>
	<li>Subitem 1.1
	<li>Subitem 1.2
      </ol>
      <li>Item 2
    </ol>
  </div> <!-- end of #toclist -->
  </td> </tr> </table>
</body>



More information about the pmwiki-users mailing list