-
Notifications
You must be signed in to change notification settings - Fork 0
/
dirlist.html
36 lines (35 loc) · 1.42 KB
/
dirlist.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
<html>
<head>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
<link rel="stylesheet" href="https://pcengines.github.io/pcengines_internal_documentation/assets/css/print.css">
</head>
<body>
<script>
function get_dir(path){
(async () => {
const response = await fetch(path);
const data = await response.json();
let htmlString = "";
// let htmlString = path + "<br>";
let path_easy = path.replace(/[^\w\s]/gi, '')
htmlString += '<button type="button" onclick="$(\'#' + path_easy + '\').toggle()">' + path+ '</button><br>';
htmlString += '<div id="' + path_easy + '">';
htmlString += '<ul>';
for (let file of data) {
if (file.type == 'dir')
{
// htmlString += `<li><a href="${file.path}">${file.name}</a> ${get_dir(path+'/'+file.name)} </li>`;
htmlString += `<li><a href="${file.path}">${file.name}</a></li>`;
get_dir(path+'/'+file.name);
}else{
htmlString += `<li><a href="${file.path}">${file.name}</a> ${file.size} </li>`;
}
}
htmlString += '</ul>';
document.getElementsByTagName('body')[0].innerHTML += htmlString;
})()
}
get_dir('https://api.github.com/repos/pcengines/pcengines_internal_documentation/contents');
</script>
<body>
</html>