-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
130 lines (113 loc) · 4.15 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>WebRTC Available Stats Properties</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<header>
<div class="container">
<h1>WebRTC <small>Available Stats Properties</small></h1>
</div>
</header>
<div class="container">
<div id="render"></div>
</div>
<footer>
<div class="container">
<p>
©
<a
href="https://ludovic-muller.fr/"
target="_blank"
rel="noopener noreferrer"
>Ludovic Muller</a
>
<!-- LAST_UPDATE -->
</p>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lodash.min.js"></script>
<!-- this defines `devices` global variable -->
<script src="data/devices.js"></script>
<!-- this defines `data` global variable -->
<script src="data/data.js"></script>
<script>
const deviceLookup = (name) => {
const deviceElement = document.createElement("div");
if (!Object.prototype.hasOwnProperty.call(devices, name)) {
deviceElement.innerText = name;
return deviceElement;
}
const device = devices[name];
const bElement = document.createElement("p");
bElement.innerText = `${device.browser.name} ${device.browser.version}`;
deviceElement.appendChild(bElement);
if (device.os) {
const osElement = document.createElement("p");
osElement.innerText = `${device.os.name} ${device.os.version}`;
deviceElement.appendChild(osElement);
}
return deviceElement;
};
const flatten = Object.entries(data)
.map(([browser, stats]) =>
Object.entries(stats).map(([report, properties]) =>
properties.map((property) => ({ browser, report, property }))
)
)
.flat()
.flat();
const browsers = new Set(flatten.map(({ browser }) => browser));
const byReport = _.chain(flatten)
.groupBy("report")
.mapValues((report) =>
_.chain(report)
.groupBy("property")
.mapValues((property) => {
const availableIn = new Set(property.map((r) => r.browser));
return Object.fromEntries(
Array.from(browsers)
.sort()
.map((browser) => [browser, availableIn.has(browser)])
);
})
.value()
)
.value();
const render = document.getElementById("render");
Object.entries(byReport).map(([report, properties]) => {
const reportTable = document.createElement("table");
const firstRow = document.createElement("tr");
const reportTitleTable = document.createElement("td");
const reportTitle = document.createElement("h2");
reportTitle.innerText = report;
reportTitleTable.appendChild(reportTitle);
firstRow.appendChild(reportTitleTable);
Array.from(browsers).map((browser) => {
const propertySupport = document.createElement("td");
propertySupport.appendChild(deviceLookup(browser));
firstRow.appendChild(propertySupport);
});
reportTable.appendChild(firstRow);
Object.entries(properties).map(([property, browserSupport]) => {
const tableRow = document.createElement("tr");
const propertyTitle = document.createElement("td");
propertyTitle.innerText = property;
propertyTitle.className = "table-left";
tableRow.appendChild(propertyTitle);
Object.entries(browserSupport).map(([browser, supported]) => {
const propertySupport = document.createElement("td");
propertySupport.innerText = supported ? "✅" : "❌";
tableRow.appendChild(propertySupport);
});
reportTable.appendChild(tableRow);
});
render.appendChild(reportTable);
});
</script>
</body>
</html>