-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupdate.html
47 lines (45 loc) · 1.47 KB
/
update.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
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html>
<head>
<title>soundShare</title>
<style>
body { font-family: Verdana, Arial, Helvetica, sans-serif; position: relative; color: #222222; font-size: 1.0em; }
</style>
<script type="text/javascript" src="js/jsonpath.js"></script>
</head>
<body>
<button id="btn">Fetch Repo Audio File List JSON</button>
<div id="response" style="border: 1px solid blue; min-height:50px; min-width:50px;">Put what appears here in treeList.json</div>
<script type="module">
import { request } from "https://cdn.pika.dev/@octokit/request";
async function getTheSHAThenTheRepoContents() {
const result = await request('GET /repos/bubblobill/soundShare/git/trees/main?recursive=1', {
owner: 'OWNER',
repo: 'REPO',
tree_sha: 'TREE_SHA',
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
})
getRepoContents( jsonPath(result, "$..[?(@.path==`audio`)].sha")[0]);
}
async function getRepoContents(SHA) {
const result = await request('GET /repos/bubblobill/soundShare/git/trees/'+SHA+'?recursive=1', {
owner: 'OWNER',
repo: 'REPO',
tree_sha: 'TREE_SHA',
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
})
document.getElementById("response").innerText = JSON.stringify(result.data.tree);
}
function update(){
getTheSHAThenTheRepoContents();
}
window.addEventListener("load", function(){
document.getElementById("btn").addEventListener("click", update);
});
</script>
</body>
</html>