/[genomes]/quickload/styling/autoindex_strapdown.js
ViewVC logotype

Contents of /quickload/styling/autoindex_strapdown.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 167 - (show annotations)
Wed Sep 21 19:05:34 2022 UTC (18 months ago) by aloraine
File MIME type: application/javascript
File size: 1704 byte(s)
IGBF-3173 Use github link to obtain js code for strapdown indexing
1 document.addEventListener('DOMContentLoaded', function() {
2 var b = document.body, xmp, strapdown;
3
4 // Hide the page while eviscerating it.
5 b.style.display = 'none';
6
7 // Set the title, if not empty.
8 if (conf.title) document.title += ' - ' + conf.title;
9
10 // Create a script element to fetch Strapdown.js.
11 strapdown = document.createElement('script');
12 // strapdown.setAttribute('src', conf.strapdown ? conf.strapdown : 'http://strapdownjs.com/v/0.2/strapdown.js');
13 strapdown.setAttribute('src', conf.strapdown ? conf.strapdown : 'https://cdn.jsdelivr.net/gh/Naereen/StrapDown.js@master/strapdown.min.js');
14
15
16 // Create an XMP element for Strapdown.js to process.
17 xmp = document.createElement('xmp'),
18 xmp.setAttribute('theme', conf.theme);
19
20 // Loop through the body elements, accumulating text or HTML in the XMP.
21 // Mod_autoindex includes the HEADER/README as childless PRE-blocks, so they
22 // are accumulated as text. All other elements are accumulated as HTML.
23 //
24 // The reason to make the distinction between PRE-blocks with and without children
25 // is because mod_autoindex's FancyIndexing option generates the index inside a PRE.
26 // The FancyIndex PRE-blocks have many child elements, but HEADER/README PRE-blocks
27 // will have no child elements.
28 for (var c=b.children, i=0; i < c.length; i++) {
29 var e = c[i],
30 t = (e.nodeName == 'PRE' && e.children.length == 0) ? e.textContent : e.outerHTML;
31 xmp.innerHTML += t + '\n\n';
32 }
33
34 // Now that everything is copied into the XMP, clear the body.
35 while (b.lastChild) { b.removeChild(b.lastChild); }
36
37 // Insert the XMP and load Strapdown.js to render it.
38 b.appendChild(xmp);
39 b.appendChild(strapdown);
40 });

  ViewVC Help
Powered by ViewVC 1.1.26