Skip to content

Commit

Permalink
Hardcode teamseas stats
Browse files Browse the repository at this point in the history
  • Loading branch information
quackduck authored and rnicoll committed Feb 9, 2022
1 parent 2a27c16 commit 83ac289
Showing 1 changed file with 10 additions and 47 deletions.
57 changes: 10 additions & 47 deletions teamseas/script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const API_ENDPOINT = "https://such-rest.dogecoin.com/api/";
// values are now hardcoded, since the campaign has ended

function pad(num, size) {
num = num.toString()
Expand All @@ -7,64 +7,27 @@ function pad(num, size) {
}

async function fetchWalletValue() {
const res = await fetch(API_ENDPOINT + "total");
const data = await res.text()
const data = 163428
const stringToAdd = pad(parseInt(data), 6).toString()
for (let x = 0; x < stringToAdd.length; x++) {
document.getElementById(`digi-${x+1}`).innerText = stringToAdd[x]
}
}

async function fetchRecent() {
const res = await fetch(API_ENDPOINT + "recent")
const data = await res.text()
document.getElementById('recent').innerText = JSON.parse(data).value
// const stringToAdd = pad(parseInt(data), 6).toString()
// for (let x = 0; x < stringToAdd.length; x++) {
// document.getElementById(`digi-${x+1}`).innerText = stringToAdd[x]
// }
document.getElementById('recent').innerText = 1.9
}

async function fetchHighest() {
const res = await fetch(API_ENDPOINT + "largest")
const data = await res.text()
document.getElementById('highest').innerText = JSON.parse(data).value
// const stringToAdd = pad(parseInt(data), 6).toString()
// for (let x = 0; x < stringToAdd.length; x++) {
// document.getElementById(`digi-${x+1}`).innerText = stringToAdd[x]
// }
document.getElementById('highest').innerText = 25000
}

async function fetchCount() {
const res = await fetch(API_ENDPOINT + "count")
const data = await res.text()
document.getElementById('count').innerText = data
// const stringToAdd = pad(parseInt(data), 6).toString()
// for (let x = 0; x < stringToAdd.length; x++) {
// document.getElementById(`digi-${x+1}`).innerText = stringToAdd[x]
// }
document.getElementById('count').innerText = 538
}

(async function() {
if (!fetch) {
// Browser not compatible, bailing out
return
}
try {
// initial fetch
fetchWalletValue()
fetchRecent()
fetchHighest()
fetchCount()

// continuously update every 5s
setInterval(function() {
fetchWalletValue()
fetchRecent()
fetchHighest()
fetchCount()
}, 5000)
} catch (e) {
// Handle API Transport errors.
}
})();

fetchWalletValue()
fetchRecent()
fetchHighest()
fetchCount()

0 comments on commit 83ac289

Please sign in to comment.