-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathreport-specs.js
134 lines (113 loc) · 4.27 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
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
const table = document.querySelector("tbody");
const list = document.querySelector("dl");
const report = await (await fetch("spec-reports.json")).json();
const now = new Date();
function age(since) {
const then = new Date(since);
return (now - then)/(24*3600*1000);
}
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]);
if (age(spec.lastModified) > 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);
if (spec.transition.status === "complete") {
addWarning(transitionTd, "Transition complete, needs archiving");
} else if (spec.transition.date && (spec.transition.status === "pending" || spec.transition.status === "started")) {
if (age(spec.transition.date) > 365) {
addWarning(transitionTd, "Incomplete transition for more than a year");
}
}
} 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((a,b) => report.wicg.repos[a]?.lastModified?.localeCompare(report.wicg.repos[b].lastModified))) {
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];
let computedNotes = notes;
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);
if (transition.status === "complete") {
computedNotes = "transitioned, needs archiving";
} else if (transition.status === "pending") {
if (age(transition.date) > 365) {
computedNotes = "transition pending for more than a year, may need discussion";
}
}
list.append(transitionDd);
}
if (lastModified) {
const lmDd = document.createElement("dd");
lmDd.append(`Last modified on ${lastModified.split("T")[0]}`);
list.append(lmDd);
}
if (computedNotes) {
const dd = document.createElement("dd");
dd.classList.add("warning");
dd.textContent = "⚠" + computedNotes;
list.append(dd);
}
}