Skip to content

Commit

Permalink
Fixed wiki TOC toggling
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Sagot authored and sagotch committed Aug 6, 2019
1 parent 7452258 commit 5ba6eee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
28 changes: 18 additions & 10 deletions hd/etc/summary.txt
Expand Up @@ -3,23 +3,29 @@
<script>
<!--
function showTocToggle() {
show="[visualize/show/hide/summary]1";
hide="[visualize/show/hide/summary]2";
if (document.getElementById) {
show_disp=' style="display:none;"';
hide_disp='';
document.writeln('<span class="toctoggle">' +
'(<a href="javascript:toggleToc()" class="internal">' +
'<span id="showlink"' + show_disp + '>' + show + '</span>' +
'<span id="hidelink"' + hide_disp + '>' + hide + '</span>'
+ '</a>)</span>');
var anchor = document.getElementById('toctoggleanchor');
if (anchor) {
var show="[visualize/show/hide/summary]1";
var hide="[visualize/show/hide/summary]2";
var show_disp=' style="display:none;"';
var hide_disp='';
var d = document.createElement ('span') ;
d.className = 'toctoggle' ;
d.innerHTML =
' (<a href="javascript:toggleToc()" class="internal">'
+ '<span id="showlink"' + show_disp + '>' + show + '</span>'
+ '<span id="hidelink"' + hide_disp + '>' + hide + '</span>'
+ '</a>)</span>' ;
anchor.appendChild(d);
}
}

function setTocToggle() {
var cookiePos = document.cookie.indexOf("hidetoc=");
if (cookiePos > -1 && document.cookie.charAt(cookiePos + 8) == 1)
toggleToc();
}

function toggleToc() {
var toc = document.getElementById('tocinside');
var showlink = document.getElementById('showlink');
Expand All @@ -38,5 +44,7 @@ function toggleToc() {
document.cookie = "hidetoc=1";
}
}

document.addEventListener("DOMContentLoaded", (function(){showTocToggle();setTocToggle();}))
-->
</script>
10 changes: 3 additions & 7 deletions lib/wiki.ml
Expand Up @@ -325,15 +325,11 @@ let summary_of_tlsw_lines conf short lines =
let lines =
"<dl><dd>" :: "<table id=\"summary\" cellpadding=\"10\">" ::
("<tr><td align=\"" ^ conf.left ^ "\">") ::
("<div style=\"text-align:center\"><b>" ^
capitale (message_txt conf 3) ^ "</b>") ::
"<script type=\"text/javascript\">" :: "//<![CDATA[" ::
"showTocToggle()" :: "//]]>" :: "</script>" :: "</div>" ::
("<div style=\"text-align:center\" id=\"toctoggleanchor\"><b>" ^
capitale (message_txt conf 3) ^ "</b>") :: "</div>" ::
"<div class=\"summary\" id=\"tocinside\">" ::
List.rev_append rev_summary
["</div>"; "</td></tr></table>"; "</dd></dl>";
"<script type=\"text/javascript\">"; "//<![CDATA["; "setTocToggle()";
"//]]>"; "</script>"]
["</div>"; "</td></tr></table>"; "</dd></dl>"]
in
lines, sections_nums

Expand Down

0 comments on commit 5ba6eee

Please sign in to comment.