-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathreport-specs.js
108 lines (93 loc) · 3.4 KB
/
report-specs.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
const table = document.querySelector("tbody");
const list = document.querySelector("dl");
const report = await (await fetch("spec-reports.json")).json();
function addWarning(el, msg) {
el.classList.add("warning");
const warning = document.createElement("span");
warning.textContent = "⚠";
warning.title = msg;
warning.setAttribute("aria-label", msg);
el.prepend(warning);
}
for (const spec of report.wicg.specs.sort((a, b) => a.lastModified.localeCompare(b.lastModified))) {
const tr = document.createElement("tr");
const specTd = document.createElement("td");
const link = document.createElement("a");
link.href = spec.url;
link.append(spec.title);
specTd.append(link);
const repoTd = document.createElement("td");
const repoLink = document.createElement("a");
repoLink.href = `https://github.com/${spec.repo}/`;
repoLink.append(spec.repo);
repoTd.append(repoLink);
const lmTd = document.createElement("td");
lmTd.append(spec.lastModified.split("T")[0]);
const now = new Date();
const then = new Date(spec.lastModified);
const age = (now - then)/(24*3600*1000);
if (age > 365) {
addWarning(lmTd, "Not modified for more than a year");
}
const implTd = document.createElement("td");
// FIXME: browser-spec specific
for (const impl of spec.implementations) {
const img = document.createElement("img");
img.src = `https://wpt.fyi/static/${impl}_64x64.png`;
img.alt = `Implemented in ${impl}`;
img.width = 32;
implTd.append(img);
}
if (spec.implementations.length > 1) {
addWarning(implTd, "2+ implementations");
}
const refTd = document.createElement("td");
for (const ref of spec.referencedBy) {
const a = document.createElement("a");
a.href = ref.url;
a.append(ref.title);
refTd.append(a);
refTd.append(document.createElement("br"));
}
if (spec.referencedBy.length) {
addWarning(refTd, "Referenced by other specs");
}
const transitionTd = document.createElement("td");
if (spec.transition.notice) {
const transitionLink = document.createElement("a");
transitionLink.href = spec.transition.notice;
transitionLink.append(`${spec.transition.status || ""} to ${spec.transition.wgshortname} (${spec.transition.date})`);
transitionTd.append(transitionLink);
} else {
transitionTd.append(spec.transition);
}
const notesTd = document.createElement("td");
notesTd.append(spec.notes);
tr.append(specTd, repoTd, lmTd, implTd, refTd, transitionTd, notesTd);
table.append(tr);
}
for (const repo of Object.keys(report.wicg.repos).sort()) {
const dt = document.createElement("dt");
const link = document.createElement("a");
link.href = `https://github.com/${repo}`;
link.textContent = repo;
dt.append(link);
list.append(dt);
const {transition, lastModified, notes} = report.wicg.repos[repo];
if (transition?.notice) {
const transitionDd = document.createElement("dd");
const transitionLink = document.createElement("a");
transitionLink.href = transition.notice;
transitionLink.append(`${transition.status || ""} to ${transition.wgshortname} (${transition.date})`);
transitionDd.append(transitionLink);
list.append(transitionDd);
}
if (lastModified) {
const lmDd = document.createElement("dd");
lmDd.append(`Last modified on ${lastModified.split("T")[0]}`);
list.append(lmDd);
}
const dd = document.createElement("dd");
dd.append(notes);
list.append(dd);
}