-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathreport.js
172 lines (162 loc) · 6.05 KB
/
report.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
var vals = ["timeout", "error", "warnings", "ok"];
function changecss(theClass,element,value)
{
var cssRules;
if (document.all) {
cssRules = 'rules';
} else if (document.getElementById) {
cssRules = 'cssRules';
}
var added = false;
for (var S = 0; S < document.styleSheets.length; S++){
if (!document.styleSheets[S][cssRules])
continue;
for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
if(document.styleSheets[S][cssRules][R].style[element]){
document.styleSheets[S][cssRules][R].style[element] = value;
added=true;
break;
}
}
}
if(!added){
if(document.styleSheets[S].insertRule){
document.styleSheets[S].insertRule(theClass+' { '+element+': '+value+'; }',
document.styleSheets[S][cssRules].length);
} else if (document.styleSheets[S].addRule) {
document.styleSheets[S].addRule(theClass,element+': '+value+';');
}
}
}
}
function initialize(){
var show = [];
if (location.hash=="") {
show = [true, true, true, true];
} else if (location.hash.match(/^#show=/)) {
var s = location.hash.replace(/^#show=/, "");
s = s.replace(/ /g, "");
var segs = s.split(",");
for (i in vals) {
var val = vals[i];
var state = (segs.indexOf(val) > -1);
show.push(state);
}
}
for (i in show) {
document.getElementById(vals[i]).checked=show[i];
if(!show[i])
toggle(vals[i]);
}
}
function toggle(theClass) {
var fullClass = "TABLE.mainrep TR."+theClass;
var element = "display";
var show;
if(document.getElementById(theClass).checked){
show = "table-row";
if(theClass=="ok"){
changecss("TABLE.mainrep TR.abc", element, "table-row");
}
}else{
show = "none";
if(theClass=="ok"){
changecss("TABLE.mainrep TR.abc", element, "none");
}
}
changecss(fullClass, element, show)
var errors = document.getElementById("error").checked;
var warnings = document.getElementById("warnings").checked;
var timeouts = document.getElementById("timeout").checked;
var selections = 0;
if(errors)
selections = selections+2;
if(warnings)
selections = selections+1;
if(timeouts)
selections = selections+4;
changecss("TABLE.mainrep TR.warnings.error.timeout", element, "none");
changecss("TABLE.mainrep TR.warnings.error", element, "none");
changecss("TABLE.mainrep TR.warnings.timeout", element, "none");
changecss("TABLE.mainrep TR.error.timeout", element, "none");
switch(selections)
{
case 1:
changecss("TABLE.mainrep TR.warnings.error", element, "table-row");
changecss("TABLE.mainrep TR.warnings.timeout", element, "table-row");
changecss("TABLE.mainrep TR.warnings.error.timeout", element, "table-row");
break;
case 2:
changecss("TABLE.mainrep TR.warnings.error", element, "table-row");
changecss("TABLE.mainrep TR.error.timeout", element, "table-row");
changecss("TABLE.mainrep TR.warnings.error.timeout", element, "table-row");
break;
case 3:
changecss("TABLE.mainrep TR.warnings.error", element, "table-row");
changecss("TABLE.mainrep TR.error.timeout", element, "table-row");
changecss("TABLE.mainrep TR.warnings.error.timeout", element, "table-row");
break;
case 4:
changecss("TABLE.mainrep TR.warnings.timeout", element, "table-row");
changecss("TABLE.mainrep TR.error.timeout", element, "table-row");
changecss("TABLE.mainrep TR.warnings.error.timeout", element, "table-row");
break;
case 5:
changecss("TABLE.mainrep TR.warnings.timeout", element, "table-row");
changecss("TABLE.mainrep TR.error.timeout", element, "table-row");
changecss("TABLE.mainrep TR.warnings.error.timeout", element, "table-row");
break;
case 6:
changecss("TABLE.mainrep TR.error.timeout", element, "table-row");
changecss("TABLE.mainrep TR.warnings.error", element, "table-row");
changecss("TABLE.mainrep TR.warnings.error.timeout", element, "table-row");
// shouldn't there be a break here?
case 7:
changecss("TABLE.mainrep TR.warnings.error.timeout", element, "table-row");
changecss("TABLE.mainrep TR.warnings.error", element, "table-row");
changecss("TABLE.mainrep TR.warnings.timeout", element, "table-row");
changecss("TABLE.mainrep TR.error.timeout", element, "table-row");
break;
}
var on = [];
for (i in vals) {
var val = vals[i];
if (document.getElementById(val).checked) {
on.push(val);
}
}
if (on.length == vals.length)
location.hash = "";
else if (on.length == 0)
location.hash = "#show=none";
else
location.hash = "#show=" + on.join(",");
}
function setPackagesVisible(){
var i,j;
var urlstring = window.location.href
var url = new URL(urlstring);
var pkgstring = url.searchParams.get("packages");
// Skip if no packages are selected
if (pkgstring == null || pkgstring == "" || pkgstring == "/") {
return;
}
// At the beginning of the summary report html is some strange code
// to always add a trailling slash. Remove it from parameter
pkgstring = pkgstring.replace(/\/+$/, "");
var pkgs = pkgstring.split(",");
// Hide all packages
var trs = document.querySelectorAll('html>body>table>tbody>tr');
for (i = 0; i < trs.length; ++i) {
trs[i].style.display = "none";
}
// Only show selected ones
for (j in pkgs) {
var pkgselector = "[data-pkg=" + pkgs[j] + "]";
var trs = document.querySelectorAll(pkgselector);
for (i = 0; i < trs.length; ++i) {
trs[i].style.display = "table-row";
}
}
}