-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathabout.html
71 lines (59 loc) · 1.95 KB
/
about.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
<!DOCTYPE html>
<html lang="en">
<script src="/static/baidu.js"></script>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>About - chengbw</title>
<link rel="stylesheet" href="static/cc.v0.1.css">
<script src="https://cdn.bootcss.com/axios/0.18.0/axios.js"></script>
<style>
.content-wrap {
text-align: center;
margin-top: 3em;
}
.content {
font-size: 1.5em;
}
</style>
</head>
<body>
<div class="header">
<div class="menu-item"><a href="/index.html">Index</a></div>
<div class="menu-item"><a href="/about.html">About</a></div>
</div>
<div class="loader" id="id-loader"></div>
<div class="content-wrap">
<pre id="id-content" class="content"></pre>
</div>
<script>
"use strict";
//get data
let url = 'data/gs19.json';
axios.get(url)
.then(function (response) {
// console.log(response.data);
//display content
document.getElementById('id-content').innerText = get_random_content(response.data);
stop_show_loader();
}).catch(function (error) {
console.log(error);
stop_show_loader();
});
//get a random content
function get_random_content(content_list) {
let count = content_list.length;
let content = "长安一片月,万户捣衣声。\n秋风吹不尽,总是玉关情。"
if (count > 0) {
let index = Math.floor(Math.random() * count);
content = content_list[index];
}
return content;
}
function stop_show_loader() {
document.getElementById('id-loader').style.display = "none";
}
</script>
</body>
</html>