~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to libs/ksysguard/scripts/smaps/helper.js

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function getElementsByTagNames(list,obj) {
 
2
    if (!obj) var obj = document;
 
3
    var tagNames = list.split(',');
 
4
    var resultArray = new Array();
 
5
    for (var i=0;i<tagNames.length;i++) {
 
6
        var tags = obj.getElementsByTagName(tagNames[i]);
 
7
        for (var j=0;j<tags.length;j++) {
 
8
            resultArray.push(tags[j]);
 
9
        }
 
10
    }
 
11
    var testNode = resultArray[0];
 
12
    if (!testNode) return [];
 
13
    if (testNode.sourceIndex) {
 
14
        resultArray.sort(function (a,b) {
 
15
                return a.sourceIndex - b.sourceIndex;
 
16
                });
 
17
    }
 
18
    else if (testNode.compareDocumentPosition) {
 
19
        resultArray.sort(function (a,b) {
 
20
                return 3 - (a.compareDocumentPosition(b) & 6);
 
21
                });
 
22
    }
 
23
    return resultArray;
 
24
}
 
25
 
 
26
function createTOC() {
 
27
    var y = document.getElementById('innertoc');
 
28
    var a = y.appendChild(document.createElement('span'));
 
29
    a.id = 'contentheader';
 
30
    var z = y.appendChild(document.createElement('div'));
 
31
    var toBeTOCced = getElementsByTagNames('h2,h3');
 
32
    if (toBeTOCced.length < 2) return false;
 
33
 
 
34
    for (var i=0;i<toBeTOCced.length;i++) {
 
35
        var tmp = document.createElement('a');
 
36
        tmp.innerHTML = toBeTOCced[i].innerHTML;
 
37
        tmp.className = 'page';
 
38
        z.appendChild(tmp);
 
39
        if (toBeTOCced[i].nodeName == 'H3')
 
40
            tmp.className += ' indent';
 
41
        if (toBeTOCced[i].nodeName == 'H4')
 
42
            tmp.className += ' extraindent';
 
43
        var headerId = toBeTOCced[i].id || 'link' + i;
 
44
        tmp.href = '#' + headerId;
 
45
        toBeTOCced[i].id = headerId;
 
46
        if (toBeTOCced[i].nodeName == 'H1') {
 
47
            tmp.innerHTML = 'Top';
 
48
            tmp.href = '#top';
 
49
            toBeTOCced[i].id = 'top';
 
50
        }
 
51
    }
 
52
    return y;
 
53
}
 
54
 
 
55
function showFullDetailsTable() {
 
56
    var table = document.getElementById('fullDetails');
 
57
    table.style.display = 'block';
 
58
    var link = document.getElementById('showFullDetailsLink');
 
59
    link.style.display = 'none';
 
60
}
 
61
function showFullLibrarySummary(tbodyId, aId) {
 
62
    var tbody = document.getElementById(tbodyId);
 
63
    if(tbody.style.display == 'none') {
 
64
        //show it again
 
65
        tbody.style.display = '';
 
66
        document.getElementById(aId).innerHTML = 'hide';
 
67
    } else {
 
68
        tbody.style.display = 'none';
 
69
        document.getElementById(aId).innerHTML = 'more';
 
70
    }
 
71
}