-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoriginalindex.html
90 lines (86 loc) · 2.88 KB
/
originalindex.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<html lang="en">
<head><title>Brads GitHub</title>
<style>
body {
background-color: #666;
color: #eee;
}
</style></head>
<body>
<script type="module">
function outputGHAPI(type) {
alert("This is the first.");
if (type == "dir") {
window.onload = async () => {
const response = await fetch(`https://api.github.com/repos/brad457/brad457.github.io/contents${pathname}`)
const results = await response.json()
// get directory listing request results
render(document.body, html`
<tr><td>Object Type</td><td>Object Name</td><td>Size</td></tr>
${dir_results.filter(el => el.type === 'dir').map(el => html`
<tr><td><a
class="directory"
href="${`https://brad457.github.io/${pathname}${el.name}`}"><img src="folder.png" alt="${el.name}" /></a></td><td><a
class="directory"
href="${`https://brad457.github.io/${pathname}${el.name}`}">${el.name}</a></td><td></td></tr>`)}
`)
}
}
if (type == "file") {
window.onload = async () => {
const response = await fetch(`https://api.github.com/repos/brad457/brad457.github.io/contents${pathname}`)
const results = await response.json()
render(document.body, html`
<tr><td>Object Type</td><td>Object Name</td><td>Size</td></tr>
${file_results.filter(el => el.type === 'file').map(el => html`
<tr><td><a
class="file"
href="${`https://brad457.github.io/${pathname}${el.name}`}"><img src="file.png" alt="${el.name}" /></a></td><td><a
class="file"
href="${`https://brad457.github.io/${pathname}${el.name}`}">${el.name}</a></td><td>formatBytes(${el.size})</td></tr>`)}
`)
}
}
// Test if GitHub Pages request returned results
//document.write(results);
}
function listDIRs() {
// alert("This is the listDIRs");
console.log("listDIRs started");
outputGHAPI("dir")
}
function listFiles() {
// alert("This is the listFiles.");
console.log("listFiles started");
outputGHAPI("file")
}
function addLoadEvent(func) {
console.log("addLoadEvent started");
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
console.log("addLoadEvent" + func + "Finished");
}
addLoadEvent(listDIRs);
// 2nd and 3rd Load Events Comment Out - BEGIN
//addLoadEvent(listFiles);
/** addLoadEvent(function() {
console.log("addLoadEvent function() started");
document.body.style.backgroundColor = '#EFDF95';
}) **/
// 2nd and 3rd Load Events Comment Out - END
</script>
<img src="https://bradsgit.tk/hackerman.png" />
<br /> Brad's <b>GitHub Pages</b> Website.
<br /><br /> Index and more coming soon...
</body>
</html>