From: Dietmar Maurer Date: Mon, 7 Nov 2016 15:47:00 +0000 (+0100) Subject: rename dasciidoc/asciidoc.js -> asciidoc/mediawiki-asciidoc.js X-Git-Url: https://git.proxmox.com/?p=pve-docs.git;a=commitdiff_plain;h=d2e80213b5c3dcd626a1190c604eca0735eeba8e rename dasciidoc/asciidoc.js -> asciidoc/mediawiki-asciidoc.js --- diff --git a/asciidoc/asciidoc.js b/asciidoc/asciidoc.js deleted file mode 100644 index 93c6ee2..0000000 --- a/asciidoc/asciidoc.js +++ /dev/null @@ -1,102 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// asciidoc JS helper for Proxmox VE mediawiki pages -// -// code based on original asciidoc.js, but re-written using jQuery -// -////////////////////////////////////////////////////////////////////////// - -var asciidoc = { - - // toc generator - toc: function ($content) { - var tocholder = $content.find('#toc'); - - if (!tocholder) { - return; - } - - tocholder.html(''); - tocholder.hide(); - - var html = "

Contents

"; - - if (n > 3) { - tocholder.html(html); - tocholder.show(); - } - }, - - // footnote generator - footnotes: function ($content) { - var noteholder = $content.find('#footnotes'); - if (!noteholder) { - return; - } - - noteholder.html(''); - - // Rebuild footnote entries. - var refs = {}; - var n = 0; - var inner_html = ''; - - $content.find("span.footnote").each(function(){ - n++; - var span = jQuery(this); - var note = span.attr("data-note"); - var id = span.attr("id"); - if (!note) { - // Use [\s\S] in place of . so multi-line matches work. - // Because JavaScript has no s (dotall) regex flag. - note = span.html().match(/\s*\[([\s\S]*)]\s*/)[1]; - span.html("[" + n + - "]"); - span.attr("data-note", note); - } - inner_html += - "
" + - "" + - n + ". " + note + "
"; - - if (id != null) { refs["#"+id] = n; } - }); - - if (inner_html) { noteholder.html("
" + inner_html); } - - if (n != 0) { - // process footnoterefs. - $content.find("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]; - span.html("[" + n + "]"); - }); - } - } -}; - -// add init to mediawiki resource loader queue -(window.RLQ=window.RLQ||[]).push(function(){ - mw.hook('wikipage.content').add(function($content) { - asciidoc.toc($content); - asciidoc.footnotes($content); - }); -}); diff --git a/asciidoc/mediawiki-asciidoc.js b/asciidoc/mediawiki-asciidoc.js new file mode 100644 index 0000000..93c6ee2 --- /dev/null +++ b/asciidoc/mediawiki-asciidoc.js @@ -0,0 +1,102 @@ +////////////////////////////////////////////////////////////////////////// +// asciidoc JS helper for Proxmox VE mediawiki pages +// +// code based on original asciidoc.js, but re-written using jQuery +// +////////////////////////////////////////////////////////////////////////// + +var asciidoc = { + + // toc generator + toc: function ($content) { + var tocholder = $content.find('#toc'); + + if (!tocholder) { + return; + } + + tocholder.html(''); + tocholder.hide(); + + var html = "

Contents

"; + + if (n > 3) { + tocholder.html(html); + tocholder.show(); + } + }, + + // footnote generator + footnotes: function ($content) { + var noteholder = $content.find('#footnotes'); + if (!noteholder) { + return; + } + + noteholder.html(''); + + // Rebuild footnote entries. + var refs = {}; + var n = 0; + var inner_html = ''; + + $content.find("span.footnote").each(function(){ + n++; + var span = jQuery(this); + var note = span.attr("data-note"); + var id = span.attr("id"); + if (!note) { + // Use [\s\S] in place of . so multi-line matches work. + // Because JavaScript has no s (dotall) regex flag. + note = span.html().match(/\s*\[([\s\S]*)]\s*/)[1]; + span.html("[" + n + + "]"); + span.attr("data-note", note); + } + inner_html += + "
" + + "" + + n + ". " + note + "
"; + + if (id != null) { refs["#"+id] = n; } + }); + + if (inner_html) { noteholder.html("
" + inner_html); } + + if (n != 0) { + // process footnoterefs. + $content.find("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]; + span.html("[" + n + "]"); + }); + } + } +}; + +// add init to mediawiki resource loader queue +(window.RLQ=window.RLQ||[]).push(function(){ + mw.hook('wikipage.content').add(function($content) { + asciidoc.toc($content); + asciidoc.footnotes($content); + }); +}); diff --git a/asciidoc/mediawiki.conf b/asciidoc/mediawiki.conf index 4c155f6..2fe858c 100644 --- a/asciidoc/mediawiki.conf +++ b/asciidoc/mediawiki.conf @@ -534,7 +534,7 @@ bodydata=| [header] template::[toc]