-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
159 lines (135 loc) · 4.37 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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>1INCH Daily</title>
<meta name="description" content="1INCH Daily">
<meta name="author" content="Belactriple9">
<!-- <link rel="stylesheet" href="styles.css"> -->
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Special+Elite&display=swap" rel="stylesheet">
<!-- Open Graph -->
<meta name="og:title" content="1INCH Daily" />
<meta name="og:url" content="https://timdeschryver.dev/posts/gridsome-social-cards" />
<meta name="og:description" content="Average daily $1INCH price increase" />
<meta name="og:type" content="article" />
<meta name="og:image" content="/social.png" />
<!-- Twitter -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:creator" content="@belactriple9" />
<meta name="twitter:title" content="1inch Daily" />
<meta name="twitter:description" content="Average daily $1INCH price increase" />
<meta name="twitter:image" content="/social.png" />
</head>
<body>
<div class="container">
<div class="content">
<div>
<!-- <p class="text">On Average $1INCH Goes Up</p> -->
<p class="text">$1INCH Price is currently</p>
<p class="number transparent" id="number">$0</p>
<!-- <p class="text">Every Day</p> -->
</div>
</div>
<footer>By <a class="handle" href="https://twitter.com/1inch"> @1inch</a> <span class="source">(<a
href="https://github.com/belactriple9/1inch-daily">source</a>)</span></footer>
</div>
</div>
<script>
// function handleData(data) {
// const genesis = new Date(2020, 11, 24);
// const now = new Date();
// const deltaSeconds = now.getTime() - genesis.getTime();
// const deltaDays = deltaSeconds / (1000 * 3600 * 24);
// const inchDaily = data.ticker.price / deltaDays;
// const el = document.getElementById("number");
// if (el) {
// el.innerHTML = `\$${inchDaily.toFixed(8)}`;
// el.classList.remove("transparent")
// }
// }
function handleData(data) {
data = parseInt(data);
const price = data / 10**6;
const el = document.getElementById("number");
if (el) {
el.innerHTML = `\$${price.toFixed(6)}`;
el.classList.remove("transparent")
}
}
function fetchAndHandleData() {
fetch("https://cloudflare-eth.com", {
"headers": {
"accept": "*/*",
},
"referrer": "https://etherscan.io/",
"referrerPolicy": "origin-when-cross-origin",
"body": "{\"jsonrpc\":\"2.0\",\"id\":3436994882953190,\"method\":\"eth_call\",\"params\":[{\"from\":\"0x0000000000000000000000000000000000000000\",\"data\":\"0x802431fb000000000000000000000000111111111117dc0aa78b770fa6a738034120c302000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000\",\"to\":\"0x0addd25a91563696d8567df78d5a01c9a991f9b8\"},\"latest\"]}",
"method": "POST",
"mode": "cors",
"credentials": "omit"
}).then(response => response.json())
.then(data => {
handleData(data.result);
});
}
fetchAndHandleData();
setTimeout(() => {
fetchAndHandleData();
}, 12000)
// TODO: error handling
// fetch('https://api.cryptonator.com/api/ticker/1inch-usd')
// .then(response => response.json())
// .then(data => handleData(data))
</script>
</body>
<style>
body {
font-family: 'Special Elite', cursive;
background-image: linear-gradient(to right, rgba(13, 24, 42), rgba(8, 12, 21), rgba(28, 19, 38));
}
footer {
display: flex;
justify-content: center;
margin-bottom: 1rem;
color: white;
}
a:link {
color: inherit;
}
a:visited {
color: inherit;
}
.container {
min-height: 100vh;
display: flex;
flex-direction: column;
}
.content {
display: flex;
align-items: center;
justify-content: center;
flex: 1;
}
.text {
font-size: 2rem;
text-align: center;
padding: 0;
margin: 0;
color: white;
}
.number {
font-size: 6rem;
text-align: center;
padding: 0;
margin: 4rem 0 2rem 0;
color: white;
}
.transparent {
color: transparent;
}
.handle {
margin: 0 0.5rem 0 0.5rem;
}
</style>
</html>j