-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotindex.html
39 lines (36 loc) · 1.28 KB
/
notindex.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
<html>
<body>
<script>
(async () => {
const baseUrl = 'https://jostinternational.github.io/Fifth-Wheel/';
const apiUrl = 'https://api.github.com/repos/JOSTInternational/Fifth-Wheel/contents/';
async function fetchDirectory(path) {
const response = await fetch(apiUrl + path);
const data = await response.json();
let htmlString = '<ul>';
for (let file of data) {
const fileUrl = baseUrl + file.path;
if (file.type === 'dir') {
htmlString += `<li><a href="${fileUrl}" class="dir-link">${file.name}</a></li>`;
} else {
htmlString += `<li><a href="${fileUrl}">${file.name}</a></li>`;
}
}
htmlString += '</ul>';
document.getElementsByTagName('body')[0].innerHTML = htmlString;
// Add event listeners to directory links
const dirLinks = document.getElementsByClassName('dir-link');
for (let link of dirLinks) {
link.addEventListener('click', function(event) {
event.preventDefault();
const path = this.getAttribute('href').replace(baseUrl, '');
fetchDirectory(path);
});
}
}
// Fetch the root directory
fetchDirectory('');
})()
</script>
</body>
</html>