-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
130 lines (116 loc) · 4.13 KB
/
Copy pathindex.html
File metadata and controls
130 lines (116 loc) · 4.13 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!doctype html>
<html lang="zh-CN">
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-142586045-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'UA-142586045-1');
</script>
<meta charset="UTF-8">
<meta content="origin" name="referrer">
<link rel="icon" type="image/x-icon" href="/images/favicon.ico">
<link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico">
<title>ONE 到一块了么?</title>
<style type="text/css">
body,
h1 {
margin: 0;
padding: 0;
}
html,
body {
height: 100%;
}
.container {
width: 100%;
height: 50%;
display: flex;
align-items: center;
justify-content: center;
}
.top-container {
background-color: black;
}
.bottom-container {
background-color: white;
}
.title {
font-size: 7vw;
}
.top-title {
color: white;
}
.bottom-title {
color: black;
}
</style>
</head>
<body>
<div class="container top-container">
<h1 class="title top-title">ONE 到一块了么?</h1>
</div>
<div class="container bottom-container">
<h1 id="result" class="title bottom-title"></h1>
</div>
<script type="text/javascript" charset="UTF-8">
let CHINESE_NUMBER_MAP = new Map();
CHINESE_NUMBER_MAP.set('0', '');
CHINESE_NUMBER_MAP.set('1', '壹');
CHINESE_NUMBER_MAP.set('2', '贰');
CHINESE_NUMBER_MAP.set('3', '叁');
CHINESE_NUMBER_MAP.set('4', '肆');
CHINESE_NUMBER_MAP.set('5', '伍');
CHINESE_NUMBER_MAP.set('6', '陆');
CHINESE_NUMBER_MAP.set('7', '柒');
CHINESE_NUMBER_MAP.set('8', '捌');
CHINESE_NUMBER_MAP.set('9', '玖');
function getChinesePrice(price) {
let str = price.toString();
let dotIndex = str.indexOf('.');
let yuan = CHINESE_NUMBER_MAP.get(str.substring(dotIndex - 1, dotIndex));
let jiao = CHINESE_NUMBER_MAP.get(str.substring(dotIndex + 1, dotIndex + 2));
let fen = CHINESE_NUMBER_MAP.get(str.substring(dotIndex + 2, dotIndex + 3));
var yuanTitle = '';
if (yuan.length > 0) {
yuanTitle = yuan + '块';
}
var jiaoTitle = '';
if (jiao.length > 0) {
jiaoTitle = jiao + '毛';
}
var fenTitle = '';
if (fen.length > 0) {
fenTitle = fen + '分';
}
if (yuan.length > 0) {
return yuanTitle + jiaoTitle;
} else {
return jiaoTitle + fenTitle;
}
}
function checkONEPrice() {
fetch("https://api.coingecko.com/api/v3/coins/one?localization=false&tickers=false&market_data=true&community_data=false&developer_data=false&sparkline=false")
.then(rsp => rsp.json())
.then(json => {
let price = parseFloat(json.market_data.current_price.cny);
let result = document.getElementById("result");
if (price >= 10) {
result.innerHTML = "到了!现价 " + parseInt(price) + " 块钱";
} else if (price >= 1) {
result.innerHTML = "到了!现在大概" + getChinesePrice(price) + "钱";
} else if (price >= 0.01) {
result.innerHTML = "没有,现在大概" + getChinesePrice(price) + "钱";
} else {
result.innerHTML = "没有,现在不到壹分钱";
}
})
.catch(e => { console.log() });
}
checkONEPrice();
window.setInterval(checkONEPrice, 15000);
</script>
</body>
</html>