This is now using more standard JavaScript, and no longer depends on anyone elses code. The following is a patch for UseMod v0.92. Note: I have tested this with Mozilla and Internet Explorer. It does not work with Netscape v4 (as far as I can tell).
-- KevinTaylor
How about some screenshots? Really! If ever a picture was worth a thousand words...
31d30 < 938c937 < my ($id, $title, $oldId, $extraHeader) = @_; --- > my ($id, $title, $oldId) = @_; 949c948 < $result .= &GetHtmlHeader("$SiteName: $title", $extraHeader); --- > $result .= &GetHtmlHeader("$SiteName: $title"); 996c995 < my ($title, $headExtra) = @_; --- > my ($title) = @_; 1016,1019d1014 < if (defined ($headExtra)) < { < $html .= $headExtra; < } 1109d1103 < $bartext .= " | " . &GetTreeLink($id, T('Tree')); 2465,2466d2458 < } elsif ($action eq "tree") { < &DoTree($id) if &ValidIdOrDie ($id); 4047,4168c4039 < < sub GetTreeLink { < my ($id, $name) = @_; < < return &ScriptLink("action=tree&id=$id", $name); < } < < sub DoTree { < my ($id) = @_; < < my @links = GetPageLinks ($id, 1, 0, 0); < @links = sort (@links); < < my $script =<<'SCRIPT'; < <script language="JavaScript1.2"> < < function change(id){ < if (document.all) < { < // Internet Explorer - I do something different < // here, as using getElementById (Which IE supports) < // does funny things for nested items < var srcIdx = event.srcElement.sourceIndex < var el = document.all[srcIdx+1] < if (el.id == id) < { < if (el.style.display=="none") { < el.style.display='' < } < else { < el.style.display="none" < } < } < } < else if(document.getElementById) < { < // The W3C Standard DOM way < var el = document.getElementById(id) < if (el.style.display=="none") { < el.style.display='' < } < else { < el.style.display="none" < } < } < else < { < // Don't do Netscape 4 ... < return < } < } < < //--> < </script> < SCRIPT < < print &GetHeader($id, &QuoteHtml(T('Tree View')), '', $script); < print "<p>Link Tree View for $id\n<ul>\n"; < < # Output the top-level page < print " <li>".&GetPageLink($id)."</li>\n"; < < # Then the next set of entries < my $headCount = 0; < my %lseen = (); < $lseen{$id}++; < foreach my $l (@links) < { < next if (defined ($lseen{$l})); < $lseen{$l}++; < < print " <li onClick=\"javascript:change(\'listHead".$headCount."\')\"><b>$l</b></li>\n"; < print " <ul id=\"listHead".$headCount."\" style=\"display:none\">\n"; < $headCount++; < print " <li>".&GetPageLink($l)."</li>\n"; < my @sublinks = GetPageLinks ($l, 1, 0, 0); < @sublinks = sort (@sublinks); < my %slseen = (); < foreach my $sl (@sublinks) < { < next if (defined ($slseen{$sl})); < $slseen{$sl}++; < < if (defined ($lseen{$sl})) < { < # Output, but with no link < print " <li><i>$sl</i></li>\n"; < } < else < { < print " <li onClick=\"javascript:change(\'listHead".$headCount."\')\"><b>$sl</b></li>\n"; < print " <ul id=\"listHead".$headCount."\" style=\"display:none\">\n"; < $headCount++; < print " <li>". &GetPageLink($sl) . "</li>\n"; < < my @subsublinks = GetPageLinks ($sl, 1, 0, 0); < @subsublinks = sort (@subsublinks); < my %sslseen = (); < foreach my $ssl (@subsublinks) < { < next if (defined ($sslseen{$ssl})); < $sslseen{$ssl}++; < < if ((defined ($lseen{$ssl})) || (defined ($slseen{$ssl}))) < { < # Output, but with no link < print " <li><i>$ssl</i></li>\n"; < } < else < { < print " <li>". &GetPageLink($ssl) . "</li>\n"; < } < } < print " </ul>\n"; < } < } < print " </ul>\n"; < } < < print "</ul>\n<hr>\n"; < print &GetFooterText ($id, ''); < } --- > #END_OF_OTHER_CODE
This works well in 1.0 too. Here's some context:
Changed lines in sub GetHeader:
my ($id, $title, $oldId, $extraHeader) = @_; $result .= &GetHtmlHeader("$SiteName: $title", $extraHeader);
Change first line in sub GetHtmlHeader:
my ($title, $headExtra) = @_;
(and add this before the head tag is closed)
if (defined ($headExtra)) { $html .= $headExtra; }
Add to sub GetGotoBar:
$bartext .= " | " . &GetTreeLink($id, T('Tree'));Add to sub DoOtherRequest:
} elsif ($action eq "tree") { &DoTree($id) if &ValidIdOrDie ($id);
Drop the subs in before #END_OF_OTHER_CODE and load action=tree&id=PageName? and behold a most excellent patch.