-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
405 lines (346 loc) · 13.1 KB
/
Copy pathindex.html
File metadata and controls
405 lines (346 loc) · 13.1 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>VDA 231-301 Schema Repository</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
background-color: #f8f9fa;
color: #333;
}
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
border-radius: 12px;
margin-bottom: 30px;
text-align: center;
box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
.header h1 {
margin: 0;
font-size: 2.5em;
font-weight: 300;
}
.header p {
margin: 10px 0 0 0;
opacity: 0.9;
font-size: 1.1em;
}
.breadcrumb {
background: white;
padding: 15px 20px;
border-radius: 8px;
margin-bottom: 20px;
border-left: 4px solid #667eea;
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.breadcrumb a {
color: #667eea;
text-decoration: none;
font-weight: 500;
}
.breadcrumb a:hover {
text-decoration: underline;
}
.directory-list {
background: white;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
.list-header {
background: #f8f9fa;
padding: 20px;
border-bottom: 1px solid #e9ecef;
font-weight: 600;
color: #495057;
}
.item {
display: flex;
align-items: center;
padding: 15px 20px;
border-bottom: 1px solid #f1f3f4;
transition: background-color 0.2s ease;
}
.item:hover {
background-color: #f8f9fa;
}
.item:last-child {
border-bottom: none;
}
.icon {
width: 24px;
height: 24px;
margin-right: 15px;
flex-shrink: 0;
}
.item-name {
flex-grow: 1;
font-weight: 500;
}
.item-name a {
color: #333;
text-decoration: none;
display: block;
}
.item-name a:hover {
color: #667eea;
}
.item-info {
color: #6c757d;
font-size: 0.9em;
margin-left: auto;
}
.folder-icon {
fill: #ffc107;
}
.file-icon {
fill: #17a2b8;
}
.json-icon {
fill: #28a745;
}
.footer {
text-align: center;
margin-top: 40px;
padding: 20px;
color: #6c757d;
font-size: 0.9em;
}
.search-box {
background: white;
padding: 20px;
border-radius: 8px;
margin-bottom: 20px;
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.search-input {
width: 100%;
padding: 12px 16px;
border: 2px solid #e9ecef;
border-radius: 6px;
font-size: 16px;
transition: border-color 0.2s ease;
}
.search-input:focus {
outline: none;
border-color: #667eea;
}
</style>
</head>
<body>
<div class="header">
<h1>VDA 231-301 Schema Repository</h1>
<p>Browse and download schema files for the VDA 231-301 standard</p>
</div>
<div class="breadcrumb">
<span id="breadcrumb-path">📁 /</span>
</div>
<div class="search-box">
<input type="text" class="search-input" placeholder="Search files and folders..." id="searchInput" onkeyup="filterItems()">
</div>
<div class="directory-list">
<div class="list-header">
📋 Directory Contents
</div>
<div id="file-list">
<!-- Files will be populated by JavaScript -->
</div>
</div>
<div class="footer">
<p>VDA 231-301 Schema Repository • Hosted on GitHub Pages</p>
</div>
<script>
// GitHub repository configuration
const GITHUB_OWNER = 'VDA231-301';
const GITHUB_REPO = 'schemas';
const GITHUB_BRANCH = 'main'; // or 'gh-pages' if that's your publishing branch
const GITHUB_PAGES_URL = `https://${GITHUB_OWNER.toLowerCase()}.github.io/${GITHUB_REPO}`;
// Cache for directory contents
const directoryCache = {};
let currentPath = '/';
// Fetch directory contents from GitHub API
async function fetchDirectoryContents(path) {
// Remove leading/trailing slashes and normalize
const cleanPath = path === '/' ? '' : path.replace(/^\/+|\/+$/g, '');
// Check cache first
const cacheKey = cleanPath || 'root';
if (directoryCache[cacheKey]) {
return directoryCache[cacheKey];
}
try {
const apiUrl = `https://api.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/contents/${cleanPath}`;
const response = await fetch(apiUrl);
if (!response.ok) {
throw new Error(`GitHub API error: ${response.status}`);
}
const data = await response.json();
// Filter to only include directories and .json files
const filtered = data.filter(item => {
return item.type === 'dir' ||
(item.type === 'file' && item.name.endsWith('.json'));
});
// Cache the result
directoryCache[cacheKey] = filtered;
return filtered;
} catch (error) {
console.error('Error fetching directory contents:', error);
showError('Failed to load directory contents. Please check your internet connection.');
return [];
}
}
function showError(message) {
const fileList = document.getElementById('file-list');
fileList.innerHTML = `
<div class="item" style="color: #dc3545; padding: 20px;">
<span>⚠️ ${message}</span>
</div>
`;
}
function showLoading() {
const fileList = document.getElementById('file-list');
fileList.innerHTML = `
<div class="item" style="padding: 20px;">
<span>⏳ Loading directory contents...</span>
</div>
`;
}
function formatFileSize(bytes) {
if (!bytes || bytes === 0) return '';
const kb = bytes / 1024;
if (kb < 1) return `${bytes} B`;
if (kb < 1024) return `${kb.toFixed(1)} KB`;
return `${(kb / 1024).toFixed(1)} MB`;
}
function getIcon(item) {
// GitHub API uses 'dir' for directories
if (item.type === 'dir' || item.type === 'directory') {
return `<svg class="icon folder-icon" viewBox="0 0 24 24">
<path d="M10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6H12L10,4Z" />
</svg>`;
} else if (item.name && item.name.endsWith('.json')) {
return `<svg class="icon json-icon" viewBox="0 0 24 24">
<path d="M5,3H7V5H5V10A2,2 0 0,1 3,12A2,2 0 0,1 5,14V19H7V21H5C3.93,20.93 3.07,20.07 3,19V15A2,2 0 0,0 1,13H0V11H1A2,2 0 0,0 3,9V5A2,2 0 0,1 5,3M19,3A2,2 0 0,1 21,5V9A2,2 0 0,0 23,11H24V13H23A2,2 0 0,0 21,15V19A2,2 0 0,1 19,21H17V19H19V14A2,2 0 0,1 21,12A2,2 0 0,1 19,10V5H17V3H19Z" />
</svg>`;
} else {
return `<svg class="icon file-icon" viewBox="0 0 24 24">
<path d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z" />
</svg>`;
}
}
function formatPath(path) {
if (path === '/') return '📁 /';
return '📁 ' + path.split('/').filter(p => p).map(p => p).join(' / ');
}
async function renderDirectory(path) {
// Show loading state
showLoading();
// Update breadcrumb
document.getElementById('breadcrumb-path').textContent = formatPath(path);
// Fetch directory contents
const items = await fetchDirectoryContents(path);
const fileList = document.getElementById('file-list');
fileList.innerHTML = '';
// Add back button if not in root
if (path !== '/') {
const pathParts = path.split('/').filter(p => p);
const parentPath = pathParts.length > 1 ? '/' + pathParts.slice(0, -1).join('/') : '/';
const backItem = document.createElement('div');
backItem.className = 'item';
backItem.innerHTML = `
<svg class="icon" style="fill: #6c757d;" viewBox="0 0 24 24">
<path d="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z" />
</svg>
<div class="item-name">
<a href="#" onclick="navigateTo('${parentPath}'); return false;">..</a>
</div>
<div class="item-info">Parent Directory</div>
`;
fileList.appendChild(backItem);
}
// Sort items: directories first, then files alphabetically
items.sort((a, b) => {
if (a.type === b.type) {
return a.name.localeCompare(b.name);
}
return a.type === 'dir' ? -1 : 1;
});
// Add directories and files from GitHub API
items.forEach(item => {
const itemElement = document.createElement('div');
itemElement.className = 'item';
itemElement.setAttribute('data-name', item.name.toLowerCase());
const isDirectory = item.type === 'dir';
const itemPath = path === '/' ? `/${item.name}` : `${path}/${item.name}`;
// Construct GitHub Pages URL for files
const href = isDirectory ? `#` : `${GITHUB_PAGES_URL}${itemPath}`;
const onclick = isDirectory ? `navigateTo('${itemPath}'); return false;` : '';
// Format file info
let itemInfo = '';
if (isDirectory) {
itemInfo = 'Directory';
} else if (item.size) {
itemInfo = formatFileSize(item.size);
} else {
itemInfo = 'JSON Schema';
}
itemElement.innerHTML = `
${getIcon(item)}
<div class="item-name">
<a href="${href}" ${onclick ? `onclick="${onclick}"` : ''} ${isDirectory ? '' : 'target="_blank"'}>${item.name}</a>
</div>
<div class="item-info">${itemInfo}</div>
`;
fileList.appendChild(itemElement);
});
// Show message if directory is empty
if (items.length === 0 && path === '/') {
fileList.innerHTML = `
<div class="item" style="padding: 20px; color: #6c757d;">
<span>📭 No JSON schemas found in this repository.</span>
</div>
`;
}
}
function navigateTo(path) {
currentPath = path || '/';
renderDirectory(currentPath);
// Update URL hash
if (path && path !== '/') {
window.location.hash = path;
} else {
window.location.hash = '';
}
}
function filterItems() {
const searchTerm = document.getElementById('searchInput').value.toLowerCase();
const items = document.querySelectorAll('.item[data-name]');
items.forEach(item => {
const name = item.getAttribute('data-name');
if (name.includes(searchTerm)) {
item.style.display = 'flex';
} else {
item.style.display = 'none';
}
});
}
// Handle browser back/forward
window.addEventListener('hashchange', function() {
const path = window.location.hash.substring(1) || '/';
currentPath = path;
renderDirectory(path);
});
// Initialize
document.addEventListener('DOMContentLoaded', function() {
const initialPath = window.location.hash.substring(1) || '/';
navigateTo(initialPath);
});
</script>
</body>
</html>