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

4.11
Last change on this file since 8127604 was 8127604, checked in by Chris Johns <chrisj@…>, on 03/20/17 at 00:42:56

Use a single top level version number.

Fix the path in the catalogue links to allow prefix testing on a local
disk.

Close #2940.

  • Property mode set to 100644
File size: 2.3 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 paintCatalogue(xml) {
33    var el_cat_title = $('#rtems-catalogue-title');
34    var el_cat = $('#rtems-catalogue');
35    /*
36     * Use jquery as XMLDocument is consider not stable on Firefox's web site.
37     */
38    var pdfIcon = 'static/images/Adobe_PDF_file_icon_32x32.png';
39    var htmlIcon = 'static/images/html-xxl.png';
40    var docs = $(xml).find('rtems-docs');
41    var date = $(docs).attr('date');
42    var title = $(docs).find('catalogue');
43    var table = catalogueHeader(date);
44    $(docs).find('doc').each(function() {
45        var name = $(this).find('name').text();
46        var title = $(this).find('title').text();
47        var release = $(this).find('release').text();
48        var version = $(this).find('version').text();
49        var html = $(this).find('html').text();
50        var pdf = $(this).find('pdf').text();
51        var singlehtml = $(this).find('singlehtml').text();
52        var empty = '<td></a></td>\n';
53        table += '<tr>\n';
54        if (html)
55            table += '<td><a href="' + html + '">' + title + '</a></td>\n';
56        else
57            table += empty;
58        if (pdf)
59            table += '<td><a href="' + pdf + '">' +
60            '<img src="' + pdfIcon + '" width="20" height="20"></a></td>\n';
61        else
62            table += empty;
63        if (singlehtml)
64            table += '<td><a href="' + singlehtml + '">' +
65            '<img src="' + htmlIcon + '" width="20" height="20"></a></td>\n';
66        else
67            table += empty;
68        table += '</tr>\n';
69    });
70    table += catalogueFooter();
71    el_cat_title.html('<h3>' + $(title).text() + '</h3>');
72    el_cat.html(table);
73}
74
75function loadCatalogue(path) {
76    var f = $.get(path, function(xml) {
77        paintCatalogue(xml);
78    }, 'xml');
79}
Note: See TracBrowser for help on using the repository browser.