source: rtems-docs/common/html-coverpage/static/rtems/js/catalogue.js @ d8a1037

4.11
Last change on this file since d8a1037 was d8a1037, checked in by Chris Johns <chrisj@…>, on 01/11/17 at 04:50:59

html: Add support for an HTML cover page for releases.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*!
2 * Catalogue 0.1
3 * Copyright 2017 Chris Johns <chrisj@rtems.org>
4 * Licensed under the MIT license
5 */
6
7function parseCatalogue(xml) {
8    if (window.DOMParser)
9    {
10        parser = new DOMParser();
11        xmlDoc = parser.parseFromString(xml, "text/xml");
12    }
13    else // Internet Explorer
14    {
15        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
16        xmlDoc.async = false;
17        xmlDoc.loadXML(xml);
18    }
19    return xmlDoc;
20}
21
22function catalogueHeader(date) {
23    return '<table class="table table-condensed table-nonfluid">\n' +
24        ' <tbody>\n' +
25        '  <thead><tr><th>Built: ' + date + '</th><th>PDF</th><th>Single Page</th></tr></thead>\n';
26}
27function catalogueFooter() {
28    return ' </tbody>\n' +
29        '</table>\n';
30}
31
32function loadCatalogue(path) {
33    var el_cat_title = $('#rtems-catalogue-title');
34    var el_cat = $('#rtems-catalogue');
35
36    var f = $.get(path, function(xml) {
37        /*
38         * Use jquery as XMLDocument is consider not stable on Firefox's web site.
39         */
40        var pdfIcon = 'static/images/Adobe_PDF_file_icon_32x32.png';
41        var htmlIcon = 'static/images/html-xxl.png';
42        var docs = $(xml).find('rtems-docs');
43        var date = $(docs).attr('date');
44        var title = $(docs).find('catalogue');
45        var table = catalogueHeader(date);
46        $(docs).find('doc').each(function() {
47            var name = $(this).find('name').text();
48            var title = $(this).find('title').text();
49            var release = $(this).find('release').text();
50            var version = $(this).find('version').text();
51            var html = $(this).find('html').text();
52            var pdf = $(this).find('pdf').text();
53            var singlehtml = $(this).find('singlehtml').text();
54            var empty = '<td></a></td>\n';
55            table += '<tr>\n';
56            if (html)
57                table += '<td><a href="' + html + '">' + title + '</a></td>\n';
58            else
59                table += empty;
60            if (pdf)
61                table += '<td><a href="' + '/' + pdf + '">' +
62                    '<img src="' + pdfIcon + '" width="20" height="20"></a></td>\n';
63            else
64                table += empty;
65            if (singlehtml)
66                table += '<td><a href="' + '/' + singlehtml + '">' +
67                    '<img src="' + htmlIcon + '" width="20" height="20"></a></td>\n';
68            else
69                table += empty;
70            table += '</tr>\n';
71        });
72        table += catalogueFooter();
73        el_cat_title.html('<h3>' + $(title).text() + '</h3>');
74        el_cat.html(table);
75    }, 'xml');
76}
Note: See TracBrowser for help on using the repository browser.