X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=asciidoc%2Fasciidoc.js;h=93c6ee245d62fedd49c1478124404f4fa3605c0d;hb=de7022fbe977672b441d6a430845695d5b26ebc9;hp=b29ab48591e7a34b9e3a0c10bf67a671f99c756f;hpb=a7d40e1f890c14383dddf97eda2e627db34dbac7;p=pve-docs.git
diff --git a/asciidoc/asciidoc.js b/asciidoc/asciidoc.js
index b29ab48..93c6ee2 100644
--- a/asciidoc/asciidoc.js
+++ b/asciidoc/asciidoc.js
@@ -8,8 +8,9 @@
var asciidoc = {
// toc generator
- toc: function () {
- var tocholder = jQuery("#toc");
+ toc: function ($content) {
+ var tocholder = $content.find('#toc');
+
if (!tocholder) {
return;
}
@@ -20,7 +21,7 @@ var asciidoc = {
var html = "
Contents
";
var n = 0;
- jQuery("#asciidoccontent div.sect1").each(function(){
+ $content.find("div.sect1").each(function(){
var h = jQuery(this).find("h2").first();
var id = h.attr("id");
if (id != null) {
@@ -41,8 +42,8 @@ var asciidoc = {
},
// footnote generator
- footnotes: function () {
- var noteholder = jQuery("#footnotes");
+ footnotes: function ($content) {
+ var noteholder = $content.find('#footnotes');
if (!noteholder) {
return;
}
@@ -54,7 +55,7 @@ var asciidoc = {
var n = 0;
var inner_html = '';
- jQuery("#asciidoccontent span.footnote").each(function(){
+ $content.find("span.footnote").each(function(){
n++;
var span = jQuery(this);
var note = span.attr("data-note");
@@ -72,15 +73,15 @@ var asciidoc = {
"";
-
+
if (id != null) { refs["#"+id] = n; }
});
if (inner_html) { noteholder.html("
" + inner_html); }
-
+
if (n != 0) {
// process footnoterefs.
- jQuery("#asciidoccontent span.footnoteref").each(function(){
+ $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.
@@ -92,8 +93,10 @@ var asciidoc = {
}
};
-jQuery(document).ready(function(){
- asciidoc.footnotes();
- asciidoc.toc();
+// 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);
+ });
});
-