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

Contents of /quickload/styling/autoindex_strapdown.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 49 - (show annotations)
Thu Sep 27 15:32:16 2018 UTC (6 years, 2 months ago) by aloraine
File MIME type: application/javascript
File size: 1536 byte(s)
Add Strapdown js and css files for more user-friendly look in Web browsers
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
14 // Create an XMP element for Strapdown.js to process.
15 xmp = document.createElement('xmp'),
16 xmp.setAttribute('theme', conf.theme);
17
18 // Loop through the body elements, accumulating text or HTML in the XMP.
19 // Mod_autoindex includes the HEADER/README as childless PRE-blocks, so they
20 // are accumulated as text. All other elements are accumulated as HTML.
21 //
22 // The reason to make the distinction between PRE-blocks with and without children
23 // is because mod_autoindex's FancyIndexing option generates the index inside a PRE.
24 // The FancyIndex PRE-blocks have many child elements, but HEADER/README PRE-blocks
25 // will have no child elements.
26 for (var c=b.children, i=0; i < c.length; i++) {
27 var e = c[i],
28 t = (e.nodeName == 'PRE' && e.children.length == 0) ? e.textContent : e.outerHTML;
29 xmp.innerHTML += t + '\n\n';
30 }
31
32 // Now that everything is copied into the XMP, clear the body.
33 while (b.lastChild) { b.removeChild(b.lastChild); }
34
35 // Insert the XMP and load Strapdown.js to render it.
36 b.appendChild(xmp);
37 b.appendChild(strapdown);
38 });

  ViewVC Help
Powered by ViewVC 1.1.26