-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
46 lines (38 loc) · 1.15 KB
/
index.js
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
async function getJson(url) {
let result = {};
await fetch(url)
.then(response => response.json())
.then(data => {
result = data;
});
return result;
};
let knownWords = document.getElementById("knownWords");
let atticusAge = document.getElementById("atticusAge");
let colonThrees = document.getElementById("colonThrees");
let stats = {words:"-",colon_threes:"-"};
let dict = [];
let bdayCountdown = document.getElementById("bdayCountdown");
let furryCountdown = document.getElementById("furryCountdown");
async function getStats() {
stats = await getJson("stats.json");
dict = await getJson("dict.json");
};
function getWords() {
if ((dict.length || 0) == 0) {
return "-";
} else {
return (dict.length || 0);
}
}
function update() {
getStats();
knownWords.innerText = getWords();
atticusAge.innerText = getAtticusAge();
colonThrees.innerText = stats.colon_threes;
bdayCountdown.innerText = formatDuration(getTimeToAtticusBirthday());
furryCountdown.innerText = formatDuration(getTimeToAtticusFurry());
}
setTimeout(update, 1);
clearInterval(update);
setInterval(update, 1000);