forked from Nemo2011/bilibili-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
history.html
68 lines (57 loc) · 1.51 KB
/
history.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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
#tag-box {
display: flex;
flex-wrap: wrap;
}
#tag-box a {
margin: .5em .5em;
padding: 0 .5em;
background-color: #43b0ff;
border-radius: 5em;
color: white;
text-decoration: none;
transition: background-color .3s;
}
#tag-box a:hover {
background-color: #6cc2ff;
}
</style>
</head>
<body>
<div id='app'>加载中,请稍候...</div>
<script>
function createTag(tagname) {
var el = document.createElement('a');
el.href = 'https://github.com/nemo2011/bilibili-api/tree/' + tagname + '/docs/';
el.innerHTML = tagname;
el.target = '_blank';
return el;
}
var $app = document.getElementById('app');
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://api.github.com/repos/nemo2011/bilibili-api/tags');
xhr.responseType = 'json';
xhr.send();
xhr.onloadend = function () {
var res = xhr.response;
$app.innerHTML = '';
var tagBox = document.createElement('div');
tagBox.id = 'tag-box';
for (var i = 0; i < res.length; i++) {
v = res[i];
tagBox.append(createTag(v.name));
}
$app.append(tagBox);
};
xhr.onerror = function () {
$app.innerHTML = '加载失败,请稍后重试。';
};
</script>
</body>
</html>