-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathequipment_viewer.html
121 lines (109 loc) · 4.09 KB
/
equipment_viewer.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DIGGS Equipment Analyzer</title>
<style>
table {
border-collapse: collapse;
width: 100%;
margin-top: 20px;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
tr:nth-child(even) {
background-color: #f9f9f9;
}
.loading {
margin: 20px;
font-style: italic;
}
</style>
</head>
<body>
<h1>DIGGS Equipment Analysis</h1>
<div id="loading" class="loading">Loading repository contents...</div>
<table id="resultsTable" style="display: none;">
<thead>
<tr>
<th>Equipment Name</th>
<th>XSD Source</th>
<th>Documentation</th>
</tr>
</thead>
<tbody id="resultsBody"></tbody>
</table>
<script>
async function fetchRepositoryContents() {
try {
const response = await fetch('https://api.github.com/repos/diggsml/schema-dev/contents/');
const data = await response.json();
return data.filter(file => file.name.endsWith('.xsd'));
} catch (error) {
console.error('Error fetching repository contents:', error);
document.getElementById('loading').textContent = 'Error loading repository contents';
return [];
}
}
async function fetchAndParseXSDFile(downloadUrl, sourceFile) {
try {
const response = await fetch(downloadUrl);
const xsdContent = await response.text();
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xsdContent, 'text/xml');
// Find all elements with substitutionGroup="diggs:AbstractEquipment"
const elements = xmlDoc.getElementsByTagName('element');
const results = [];
for (const element of elements) {
const substitutionGroup = element.getAttribute('substitutionGroup');
if (substitutionGroup === 'diggs:AbstractEquipment') {
const name = element.getAttribute('name');
const documentation = element.querySelector('documentation')?.textContent.trim() || '';
results.push({
name,
source: sourceFile,
documentation
});
}
}
return results;
} catch (error) {
console.error(`Error processing ${downloadUrl}:`, error);
return [];
}
}
function updateTable(equipment) {
const tbody = document.getElementById('resultsBody');
equipment.forEach(item => {
const row = document.createElement('tr');
row.innerHTML = `
<td>${item.name}</td>
<td>${item.source}</td>
<td>${item.documentation}</td>
`;
tbody.appendChild(row);
});
document.getElementById('loading').style.display = 'none';
document.getElementById('resultsTable').style.display = 'table';
}
async function main() {
const xsdFiles = await fetchRepositoryContents();
const allEquipment = [];
for (const file of xsdFiles) {
const equipment = await fetchAndParseXSDFile(file.download_url, file.name);
allEquipment.push(...equipment);
}
updateTable(allEquipment);
}
// Start the analysis
main();
</script>
</body>
</html>