-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
63 lines (63 loc) · 1.82 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-sacle=1, maximum-scale=1" >
</head>
<script type="text/javascript" src="./website/data.js"></script>
<script type="text/javascript">
var global_data = null;
function loadData(){
if (global_data == null || global_data.length == 0){
global_data = data;
}
return global_data;
}
function getRandomItem(){
var index = Math.floor(Math.random() * global_data.length);
var item = global_data.pop(index);
return item;
}
function setHTML(id, val){
var element = document.getElementById(id);
element.innerHTML = val;
}
function refresh(){
const data = loadData();
const item = getRandomItem();
setHTML("category", item["category"]);
setHTML("content", item["content"]);
time_created = new Date(item["time_created"]*1000);
setHTML("time_created", time_created.toLocaleString());
}
window.onload = refresh;
</script>
<style>
p {white-space: pre-line;}
html, body {
height: 100%;
}
body {
display: flex;
flex-direction: column;
}
.main {flex-grow: 1;}
/* .footer {
background-color: gray;
} */
</style>
<body>
<div class="main">
<h2>Yisheng's Bullshit Random Walker</h2>
<button type="button" onclick="refresh()">随机一条bullshit</button>
<h3 id="category"></h3>
<p id="content"></p>
<p id="time_created"></p>
</div>
<div class="footer">
<hr \>
<p>Copyright@Yisheng Gong 2023
<a href="https://github.com/gongyisheng/bullshit">Github</a> <a href="https://yishenggong.com">My Blog</a>
</p>
</div>
</body>
</html>