-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
76 lines (60 loc) · 1.71 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
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<link rel="icon" href="./favicon.ico">
<title>Days Since Last api.multiversx.com update</title>
<style>
body,
html {
font-family: source_sans, Lucida Grande, Lucida Sans, sans-serif;
margin: 0;
overflow: hidden;
}
body {
color: #23f7dd;
background-color: #1e1e1e;
}
main {
height: 100vh;
display: flex;
justify-content: center;
}
strong {
font-size: 20em;
align-self: center;
}
strong::selection {
color: #1e1e1e;
background-color: #23f7dd;
}
</style>
</head>
<body>
<main>
<strong id="text">...</strong>
</main>
<script>
const getLastCommitHash = async () => {
const about = await fetch('https://api.multiversx.com/about')
.then(response => response.json());
return about.appVersion;
};
const getLastCommitDate = async () => {
const lastCommitHash = await getLastCommitHash();
const lastCommit = await fetch(`https://api.github.com/repos/multiversx/mx-api-service/commits/${lastCommitHash}`)
.then(response => response.json());
const lastCommitDateRaw = lastCommit.commit.committer.date;
const lastCommitDate = new Date(lastCommitDateRaw);
return lastCommitDate;
};
const loadPage = async () => {
const currentDate = new Date();
const lastCommitDate = await getLastCommitDate();
const diffInMs = currentDate - lastCommitDate;
const diffInDays = diffInMs / (1000 * 60 * 60 * 24);
document.getElementById("text").innerText = parseInt(diffInDays);
};
loadPage();
</script>
</body>