Skip to content

Commit 6bd87c2

Browse files
committed
setup
1 parent d134bc9 commit 6bd87c2

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

.nojekyll

Whitespace-only changes.

index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>docs</title>
5+
</head>
6+
<body>
7+
<h1>API Version</h1>
8+
<ul id="dirlist">
9+
</ul>
10+
<script src="index.js"></script>
11+
</body>
12+
</html>

index.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
const repo = 'jeffersonlab/java-workflows';
2+
const url = 'https://api.github.com/repos/' + repo + '/contents/?ref=gh-pages';
3+
4+
const list = document.getElementById('dirlist');
5+
6+
function sortSemVer(arr, reverse = false) {
7+
let semVerArr = arr.map(i => i.replace(/(\d+)/g, m => +m + 100000)).sort();
8+
if (reverse)
9+
semVerArr = semVerArr.reverse();
10+
11+
return semVerArr.map(i => i.replace(/(\d+)/g, m => +m - 100000));
12+
}
13+
14+
function addToList(name) {
15+
//console.log('addToList', name);
16+
17+
const li = document.createElement("li");
18+
const a = document.createElement("a");
19+
a.href = name + '/';
20+
a.innerText = name;
21+
li.appendChild(a);
22+
list.appendChild(li);
23+
24+
}
25+
26+
async function fetchData() {
27+
//console.log('fetchData', url);
28+
29+
30+
const response = await fetch(url);
31+
32+
const data = await response.json();
33+
34+
//console.log(data);
35+
36+
let dirs = data.filter(function(obj) {
37+
return obj.type === 'dir';
38+
});
39+
40+
let names = dirs.map(i => i.name);
41+
42+
sorted = sortSemVer(names, true);
43+
44+
45+
sorted.forEach(addToList);
46+
47+
}
48+
49+
fetchData();

0 commit comments

Comments
 (0)