-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathcommon.js
31 lines (28 loc) · 1.16 KB
/
common.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
/* Build specification tables using JSON data */
async function buildSpecificationTables(config) {
const {document} = window;
const response = await fetch('specifications/index.json');
if(response.status !== 200) {
throw new Error('Failed retrieve specifications index.json file.');
}
const allSpecs = await response.json();
// summarize each API endpoint
for(const spec of allSpecs) {
const tableRow = document.createElement('tr');
const {name, summary, specification, category, maintainerEmail,
maintainerName, maintainerWebsite, vocabulary} = spec;
let maintainerInfo = maintainerName;
if(maintainerEmail) {
maintainerInfo += ` (<a href="mailto:${maintainerEmail}">email</a>)`;
}
if(maintainerWebsite) {
maintainerInfo += ` (<a href="${maintainerWebsite}">website</a>)`;
}
tableRow.innerHTML =
`<td style="vertical-align:top;"><a href="${specification}">${name}</a></td>` +
`<td>${summary}<br/>Maintainer: ${maintainerInfo}</td>`;
const tableBody = document.getElementById(category + '-table');
tableBody.appendChild(tableRow);
}
}
window.buildSpecificationTables = buildSpecificationTables;