2
$(document).ready(function () {
3
// Create a Table of Contents (TOC)
4
$('#content .wikipage')
5
.prepend('<div id="rpc-toc" class="wiki-toc"><h4>Contents</h4><ul /></div>');
6
function toc_entry(_this, item) {
7
return $('<li><a href="#' + _this.id + '" title="'
8
+ $(item).text().replace(/^\s+|\s+$/g, '')
9
+ '">' + _this.id.replace(/^rpc\./, '') + '</a></li>');
11
var ul = $('#rpc-toc ul');
12
$("#content").find("*[id]").each(function(index, item) {
14
if (this.tagName == 'H2') {
15
elem = toc_entry(this, item);
16
elem.css('padding-top', '0.5em');
18
if (this.tagName == 'H3') {
19
elem = toc_entry(this, item);
20
elem.css('padding-left', '1.2em');
24
$('#rpc-toc').toggle();
25
// Add anchors to headings
26
$("#content").find("h2,h3").addAnchor("Link here");