-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
86 lines (67 loc) · 3.49 KB
/
app.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
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
function updateDateTime() {
const now = new Date();
const options = { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: true };
const formattedDateTime = now.toLocaleDateString('en-US', options);
document.getElementById('current-date-time').textContent = formattedDateTime;
}
updateDateTime();
setInterval(updateDateTime, 1000); // Update every second
updateDateTime();
setInterval(updateDateTime, 1000);
var btc = document.getElementById("bitcoin");
var ltc = document.getElementById("litecoin");
var eth = document.getElementById("ethereum");
var doge = document.getElementById("dogecoin");
var btcPrice = document.getElementById("bitcoin-price");
var ltcPrice = document.getElementById("litecoin-price");
var ethPrice = document.getElementById("ethereum-price");
var dogePrice = document.getElementById("dogecoin-price");
var btcTotal = document.getElementById("bitcoin-total");
var ltcTotal = document.getElementById("litecoin-total");
var ethTotal = document.getElementById("ethereum-total");
var dogeTotal = document.getElementById("dogecoin-total");
var btcinvestedValue = 496;
var ltcinvestedValue = 98;
var dogeinvestedValue = 232;
var ethinvestedValue = 100;
var liveprice = {
"async": true,
"scroosDomain": true,
"url": "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin%2Clitecoin%2Cethereum%2Cdogecoin&vs_currencies=usd",
"method": "GET",
"headers": {}
}
$.ajax(liveprice).done(function (response){
btc.innerHTML = response.bitcoin.usd.toFixed(2);
ltc.innerHTML = response.litecoin.usd.toFixed(2);
eth.innerHTML = response.ethereum.usd.toFixed(2);
doge.innerHTML = response.dogecoin.usd.toFixed(2);
btcPrice.innerHTML = response.bitcoin.usd.toFixed(2);
ltcPrice.innerHTML = response.litecoin.usd.toFixed(2);
ethPrice.innerHTML = response.ethereum.usd.toFixed(2);
dogePrice.innerHTML = response.dogecoin.usd.toFixed(2);
var bitcoinUnits = 0.017;
var bitcoinCurrentPrice = response.bitcoin.usd;
var bitcoinTotalValue = bitcoinUnits * bitcoinCurrentPrice;
var bitcoinProfitLoss = bitcoinTotalValue - btcinvestedValue;
var litecoinUnits = 0.73;
var litecoinCurrentPrice = response.litecoin.usd;
var litecoinTotalValue = litecoinUnits * litecoinCurrentPrice;
var litecoinProfitLoss = litecoinTotalValue - ltcinvestedValue;
var ethereumUnits = 0.13;
var ethereumCurrentPrice = response.ethereum.usd;
var ethereumTotalValue = ethereumUnits * ethereumCurrentPrice;
var ethereumProfitLoss = ethereumTotalValue - ethinvestedValue;
var dogecoinUnits =1339;
var dogecoinCurrentPrice = response.dogecoin.usd;
var dogecoinTotalValue = dogecoinUnits * dogecoinCurrentPrice;
var dogecoinProfitLoss = dogecoinTotalValue - dogeinvestedValue;
document.getElementById("bitcoin-total").innerHTML = bitcoinTotalValue.toFixed(2);
document.getElementById("bitcoin-profit").innerHTML = bitcoinProfitLoss.toFixed(2);
document.getElementById("litecoin-total").innerHTML = litecoinTotalValue.toFixed(2);
document.getElementById("litecoin-profit").innerHTML = litecoinProfitLoss.toFixed(2);
document.getElementById("ethereum-total").innerHTML = ethereumTotalValue.toFixed(2);
document.getElementById("ethereum-profit").innerHTML = ethereumProfitLoss.toFixed(2);
document.getElementById("dogecoin-total").innerHTML = dogecoinTotalValue.toFixed(2);
document.getElementById("dogecoin-profit").innerHTML = dogecoinProfitLoss.toFixed(2);
});