X-Git-Url: https://git.proxmox.com/?p=pve-docs.git;a=blobdiff_plain;f=asciidoc%2Fasciidoc.js;h=fa71f7576d416cbe4cbec49046fa35806237997f;hp=5882248492cc64fc781c106dcd784da1bee14662;hb=24bec5055dc94d32972ee4aa2da52f417c30bc11;hpb=110ebe8fe1fc1bfc6b28428e1c310704313819d2 diff --git a/asciidoc/asciidoc.js b/asciidoc/asciidoc.js index 5882248..fa71f75 100644 --- a/asciidoc/asciidoc.js +++ b/asciidoc/asciidoc.js @@ -7,9 +7,42 @@ var asciidoc = { + // toc generator + toc: function () { + var tocholder = jQuery("#toc"); + if (!tocholder) { + return; + } + + tocholder.html(''); + tocholder.hide(); + + var html = "

Contents

"; + + if (n > 3) { + tocholder.html(html); + tocholder.show(); + } + }, + // footnote generator footnotes: function () { - var noteholder = $("#footnotes"); + var noteholder = jQuery("#footnotes"); if (!noteholder) { return; } @@ -21,9 +54,9 @@ var asciidoc = { var n = 0; var inner_html = ''; - $("#asciidoccontent span.footnote").each(function(){ + jQuery("#asciidoccontent span.footnote").each(function(){ n++; - var span = $(this); + var span = jQuery(this); var note = span.attr("data-note"); var id = span.attr("id"); if (!note) { @@ -47,8 +80,8 @@ var asciidoc = { if (n != 0) { // process footnoterefs. - $("#asciidoccontent span.footnoteref").each(function(){ - var span = $(this); + jQuery("#asciidoccontent span.footnoteref").each(function(){ + var span = jQuery(this); var href = span.find("a").first().attr("href"); href = href.match(/#.*/)[0]; // in case it return full URL. n = refs[href]; @@ -59,7 +92,8 @@ var asciidoc = { } }; -$(document).ready(function(){ +// add init to mediawiki resource loader queue +(window.RLQ=window.RLQ||[]).push(function(){ asciidoc.footnotes(); + asciidoc.toc(); }); -