forked from AndreLion/__
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
41 lines (40 loc) · 1022 Bytes
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>http://warmhug.github.io/__</title>
<style>
li {margin: 5px 0;}
</style>
</head>
<body>
<ul id="list"></ul>
<script>
const pre = location.href || 'http://warmhug.github.io/__/';
let html = '';
ajax('./_file.txt', res => {
// console.log(res, res.split('\n'));
res.split('\n').forEach(i => {
if (i) {
const path = i.replace('./', '');
html += `<li><a href="${pre + path}">./${path}</a></li>`
}
});
document.querySelector('#list').innerHTML = html;
})
function ajax(url, success, fail) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 400) {
success(xhr.responseText);
} else {
fail(xhr);
}
};
xhr.open("GET", url, true);
xhr.send();
}
</script>
</body>
</html>