-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
45 lines (45 loc) · 1.53 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
<!DOCTYPE html>
<html>
<head>
<script>
function pageLoad() {
getQuotes();
setInterval(() => {
getQuotes();
}, 5000);
}
function getQuotes() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
var response = xhttp.responseText;
let quote = JSON.parse(response);
document.getElementById('btcQuote').innerHTML = "" + formatCurrency(Math.round(quote.price*100)/100) + " @ " + (new Date()).toLocaleTimeString();
}
xhttp.open('GET','https://api.foxbit.com.br/rest/v3/markets/quotes?side=buy&base_currency=btc"e_currency=brl&amount=100',true);
xhttp.send();
}
function formatCurrency(amount)
{
return amount.toLocaleString('pt-br',{style: 'currency', currency: 'BRL'});
};
</script>
<style>
div {
display: flex;
position: relative;
float:left;
padding-left: 10px;
margin-top:10px;
}
</style>
</head>
<body onload="pageLoad()">
<div width="10%" style="min-width: 5%;">
<img width="40" height="40" src="images/btc-logo.png">
</div>
<div id="btcQuote" style="min-width: 90%;"></div>
<div>
Fonte: FoxBit
</div>
</body>
</html>