-
Notifications
You must be signed in to change notification settings - Fork 1
/
reportChanges.html
174 lines (144 loc) · 3.39 KB
/
reportChanges.html
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
173
174
<html>
<style>
h1, h2, h3 {
color: #555;
}
h1 { font-size: 1.3em; border-bottom: 1px solid grey; display: inline-block; margin-right: 1em;}
form { display: inline-block}
.list {
max-height: 15em;
max-width: 25%;
overflow: auto;
display: inline-block;
vertical-align: top;
border:1px solid blue;
padding:.3em;
}
.list h3 {padding: 0; margin: 0}
.list li {
cursor: pointer;
}
.list li:hover {
background: lightgrey;
}
.list .priorityLow {
color: grey;
}
.list .priorityHigh {
font-weight: bold;
}
.list .hasNote {
}
.list .hasNote::after {
content: "\2020";
padding-left: 1mm;
padding-right: 1mm;
margin-left: 2mm;
}
#details {
margin: .3em 0;
border: 1px solid grey;
padding: .3em;
}
#details img {
border: 1px dotted lightgrey;
width: 49%;
margin: 1px;
}
#details .flag {
background: lightgrey;
padding: 2pt;
border-radius: 2pt;
margin: 2pt;
}
.selected {
background: lightgreen;
}
</style>
<script>
function getData(type, url, callback) {
var xhr = new XMLHttpRequest();
xhr.addEventListener("load", function() {
callback(xhr);
});
xhr.responseType = type;
xhr.open("GET", url);
xhr.send();
}
</script>
<script>
function formSubmitted(f) {
NodeList.prototype.forEach = Array.prototype.forEach;
NodeList.prototype.map = Array.prototype.map;
document.querySelectorAll(".list ol").forEach((e) => e.innerHTML = "Loading...");
var path1 = f.path1.value;
getData("json", path1 + "/results.json", function(data1) {
document.querySelectorAll(".list ol").forEach((e) => e.innerHTML = "");
report(path1, data1.response);
});
return false;
}
function findTestInfo(id, testInfo) {
var t = testInfo.querySelector("test[id='"+id+"']");
return {
href: t.querySelector("test-href").innerHTML,
refHref: t.querySelector("reference-href").innerHTML,
flags: t.querySelectorAll("flag").map(e => e.innerHTML)
};
}
function safeEncode(str) {
return encodeURIComponent(encodeURIComponent(str));
}
function mkScreenshot(i) {
return `<a title=${i.path} href=${"changeTests/tests/" + i.id}><img src=${i.path + "/screenshot/" + safeEncode(i.id) + ".png"} /></a>`;
}
function showDetails(imgs) {
var d = imgs.map(img => mkScreenshot(img)).join("");
document.getElementById("details").innerHTML = d;
}
function selectElem(e) {
var prior = document.querySelector(".selected");
if (prior) {
prior.classList.remove("selected");
}
e.classList.add("selected");
}
function report(path1, data) {
var dataRes = data["change-tests"].results;
dataRes.forEach(function(dr) {
var e = document.createElement("li");
e.innerHTML = dr.id;
e.onclick = () => {
showDetails([
{path: path1, id: dr.id},
{path: path1.substr("data/".length), id: dr.id}
]);
selectElem(e);
}
document.getElementById(dr.change ? "changes" : "sames").appendChild(e);
});
}
</script>
<body>
<div>
<h1>Grinder reports</h1>
<form onsubmit="return formSubmitted(this);">
<input type="text" name="path1" value="data/changeTests/" autofocus/>
<input type="submit" />
</form>
</div>
<div class="list">
<h3>Changes</h3>
<ol id="changes"> </ol>
</div>
<div class="list">
<h3>Sames</h3>
<ol id="sames"> </ol>
</div>
<div class="list">
<h3>New</h3>
<ol id="new"> </ol>
</div>
<div id="details"> </div>
</body>
</html>