-
+
@@ -491,8 +491,6 @@ window.addEventListener('load', function() {
}
if (coin === 'WOW') {
fetchWowneroData(coinGeckoApiKey);
- } else if (coin === 'ZANO') {
- fetchZanoData(coinGeckoApiKey);
} else {
fetchCryptoCompareData(coin, api_key);
}
@@ -501,7 +499,7 @@ window.addEventListener('load', function() {
});
function fetchWowneroData(coinGeckoApiKey) {
- fetch(`https://api.coingecko.com/api/v3/coins/wownero/market_chart?vs_currency=usd&days=30&api_key={{coingecko_api_key}}`)
+ fetch(`https://api.coingecko.com/api/v3/coins/wownero/market_chart?vs_currency=usd&days=2&api_key={{coingecko_api_key}}`)
.then(response => {
if (!response.ok) {
throw new Error(`Error fetching data. Status: ${response.status}`);
@@ -510,31 +508,15 @@ function fetchWowneroData(coinGeckoApiKey) {
})
.then(data => {
displayWowneroData(data);
- })
- .catch(error => {
- console.error('Fetching Wownero data:', error);
- displayErrorMessage('Unable to fetch data for Wownero. Please try again later.');
+// TODO bad responses block all others from displaying properly
+// })
+// .catch(error => {
+// console.error('Fetching Wownero data:', error);
+// displayErrorMessage('Unable to fetch data for Wownero. Please try again later.');
});
}
-function fetchZanoData(coinGeckoApiKey) {
- fetch(`https://api.coingecko.com/api/v3/coins/zano/market_chart?vs_currency=usd&days=30&interval=daily&api_key={{coingecko_api_key}}`)
- .then(response => {
- if (!response.ok) {
- throw new Error(`Error fetching data. Status: ${response.status}`);
- }
- return response.json();
- })
- .then(data => {
- displayZanoData(data);
- })
- .catch(error => {
- console.error('Fetching Zano data:', error);
- displayErrorMessage('Unable to fetch data for Zano. Please try again later.');
- });
-}
-
function fetchCryptoCompareData(coin, api_key) {
fetch(`https://min-api.cryptocompare.com/data/pricemultifull?fsyms=${coin}&tsyms=USD,BTC&api_key={{chart_api_key}}`)
.then(response => {
@@ -556,10 +538,10 @@ function fetchCryptoCompareData(coin, api_key) {
const prices = data.prices;
const latestPriceUSD = prices[prices.length - 1][1];
- const priceChange24h = data.market_caps[data.market_caps.length - 1][1] / data.market_caps[data.market_caps.length - 2][1] - 1;
+ const priceChange24h = prices[prices.length - 1][1] / prices[prices.length - 24][1] - 1;
const volume24h = data.total_volumes[data.total_volumes.length - 1][1];
- document.getElementById('wow-price-usd-value').textContent = latestPriceUSD.toFixed(2) + ' $';
+ document.getElementById('wow-price-usd-value').textContent = '$ ' + latestPriceUSD.toFixed(4);
document.getElementById('wow-price-change-container').textContent = (priceChange24h * 100).toFixed(2) + '%';
document.getElementById('wow-volume-24h').textContent = volume24h.toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' USD';
@@ -575,31 +557,6 @@ function fetchCryptoCompareData(coin, api_key) {
const priceBTC = latestPriceUSD / latestPriceBTC;
document.getElementById('wow-price-btc').textContent = priceBTC.toFixed(8) + ' BTC';
- }
-
-function displayZanoData(data) {
- const prices = data.prices;
-
- const latestPriceUSD = prices[prices.length - 1][1];
- const priceChange24h = data.market_caps[data.market_caps.length - 1][1] / data.market_caps[data.market_caps.length - 2][1] - 1;
- const volume24h = data.total_volumes[data.total_volumes.length - 1][1];
-
- document.getElementById('zano-price-usd-value').textContent = latestPriceUSD.toFixed(2) + ' $';
- document.getElementById('zano-price-change-container').textContent = (priceChange24h * 100).toFixed(2) + '%';
- document.getElementById('zano-volume-24h').textContent = volume24h.toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' USD';
-
- const priceChangeContainer = document.getElementById('zano-price-change-container');
- if (priceChange24h >= 0) {
- priceChangeContainer.innerHTML = positivePriceChangeHTML(priceChange24h * 100);
- } else {
- priceChangeContainer.innerHTML = negativePriceChangeHTML(priceChange24h * 100);
- }
-
- const latestPriceBTC = parseFloat(data.prices[data.prices.length - 1][1]);
- // Todo fix value USD -> BTC
- const priceBTC = latestPriceUSD / latestPriceBTC;
-
- document.getElementById('zano-price-btc').textContent = priceBTC.toFixed(8) + ' BTC';
}
function displayCoinData(coin, data) {
@@ -607,13 +564,24 @@ function displayCoinData(coin, data) {
const priceBTC = data.RAW[coin].BTC.PRICE;
const priceChange1d = data.RAW[coin].USD.CHANGEPCT24HOUR;
const volume24h = data.RAW[coin].USD.TOTALVOLUME24HTO;
- document.querySelector(`#${coin.toLowerCase()}-price-usd`).textContent = priceUSD.toFixed(2) + ' $';
- if (coin !== 'BTC') {
- document.querySelector(`#${coin.toLowerCase()}-price-btc`).textContent = priceBTC.toFixed(8) + ' BTC';
+ const c = coin
+
+ if (c === 'BTC') {
+ document.querySelector(`#${c.toLowerCase()}-price-usd`).textContent = '$ ' + priceUSD.toFixed(1);
+ } else if (c === 'ZANO' || c === 'FIRO') {
+ document.querySelector(`#${c.toLowerCase()}-price-usd`).textContent = '$ ' + priceUSD.toFixed(3);
+ } else if (c === 'DOGE' || c === 'PIVX' || c === 'PART') {
+ document.querySelector(`#${c.toLowerCase()}-price-usd`).textContent = '$ ' + priceUSD.toFixed(4);
+ } else {
+ document.querySelector(`#${c.toLowerCase()}-price-usd`).textContent = '$ ' + priceUSD.toFixed(2);
}
- document.querySelector(`#${coin.toLowerCase()}-price-change-container`).textContent = priceChange1d.toFixed(2) + '%';
- document.querySelector(`#${coin.toLowerCase()}-volume-24h`).textContent = volume24h.toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' USD';
- const priceChangeContainer = document.querySelector(`#${coin.toLowerCase()}-price-change-container`);
+
+ if (c !== 'BTC') {
+ document.querySelector(`#${c.toLowerCase()}-price-btc`).textContent = priceBTC.toFixed(8) + ' BTC';
+ }
+ document.querySelector(`#${c.toLowerCase()}-price-change-container`).textContent = priceChange1d.toFixed(2) + '%';
+ document.querySelector(`#${c.toLowerCase()}-volume-24h`).textContent = volume24h.toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' USD';
+ const priceChangeContainer = document.querySelector(`#${c.toLowerCase()}-price-change-container`);
if (priceChange1d >= 0) {
priceChangeContainer.innerHTML = positivePriceChangeHTML(priceChange1d);
} else {
@@ -715,26 +683,6 @@ function updateChart(coinSymbol, coinGeckoApiKey) {
chart.update();
})
.catch(error => console.error('Error updating chart for Wownero:', error));
- } else if (coinSymbol === 'ZANO') {
- fetch(`https://api.coingecko.com/api/v3/coins/zano/market_chart?vs_currency=usd&days=30&interval=daily&api_key={{coingecko_api_key}}`)
- .then(response => response.json())
- .then(data => {
- const chartData = {
- labels: data.prices.map(entry => formatDate(new Date(entry[0]))),
- datasets: [{
- label: 'Zano Price (USD)',
- data: data.prices.map(entry => entry[1]),
- borderColor: 'rgba(77, 132, 240, 1)',
- backgroundColor: 'rgba(77, 132, 240, 0.1)',
- fill: true
- }]
- };
-
- chart.data = chartData;
- chart.options.scales.y.title.text = 'Price (USD) - Zano 30 DAYS';
- chart.update();
- })
- .catch(error => console.error('Error updating chart for Zano:', error));
} else {
fetch(`https://min-api.cryptocompare.com/data/v2/histoday?fsym=${coinSymbol}&tsym=USD&limit=30&api_key={{chart_api_key}}`)
.then(response => response.json())
@@ -1313,7 +1261,7 @@ const coinNameToSymbol = {
'Dash': 'DASH',
'PIVX': 'PIVX',
'Decred': 'DCR',
- 'Zano': 'Zano'
+ 'Zano': 'ZANO'
};
const exchangeRateCache = {};