-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscripts.js
More file actions
27 lines (24 loc) · 1009 Bytes
/
scripts.js
File metadata and controls
27 lines (24 loc) · 1009 Bytes
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
async function listDirectory(url, directory) {
const list = await fetch(url).then(res => res.json());
const dir = list.tree.find(node => node.path === directory);
if (dir) {
const list = await fetch(dir.url).then(res => res.json());
return list.tree.map(node => node.url);
}
}
async function listFiles(url, extension, target) {
const list = await fetch(url).then(res => res.json());
let htmlString = '<ul>';
Object.keys(list.tree).forEach(key => {
var package = list.tree[key].path;
if (package.includes(extension))
htmlString += `<li><a href="https://awawa-dev.github.io/repo/others/${package}">${package}</a></li>`;
});
htmlString += '</ul>';
target.innerHTML = htmlString;
}
listDirectory(`https://api.github.com/repos/awawa-dev/awawa-dev.github.io/git/trees/upload`,'repo').
then(result => {
listFiles(result, '.rpm', document.getElementById('RpmTarget'));
listFiles(result, '.pkg.tar.zst', document.getElementById('ArchTarget'));
});