Skip to content

Commit

Permalink
fix rate
Browse files Browse the repository at this point in the history
  • Loading branch information
nnslvp committed Apr 16, 2024
1 parent ba6f0d5 commit 23bc9a8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
6 changes: 3 additions & 3 deletions calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ function generateTable(calculatorForm) {
const currencyValue = "USD";
const electricityCostsValue = calculatorForm.electricity_costs.value;

Promise.all([fetchRate(), fetchPoolProfit()]).then(function([object1, object2]) {
Promise.all([fetchRate(), fetchPoolProfit()]).then(function([{rate}, {profit}]) {
let tbody = document.getElementsByTagName('tbody')[0];
tbody.innerHTML = "";

let reward = object2.profit * hashrateValue;
let income = getPoolProfitUSD(object1.rate, reward);
let reward = profit * hashrateValue;
let income = getPoolProfitUSD(rate.value, reward);

addRow(
tbody,
Expand Down
2 changes: 1 addition & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function showPoolLatestBlockAt(date) {
function init() {
fetchPoolProfit().then(({ profit }) => {
showPoolProfit(profit);
fetchCurrencyInfo().then(({ rate }) => showPoolProfitUSD(profit, rate));
fetchCurrencyInfo().then(({ rate: {value} }) => showPoolProfitUSD(profit, value));
});

fetchPoolHashRate().then(({ hashrate }) => {
Expand Down
45 changes: 23 additions & 22 deletions stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ function amountUSD(amountInAlph, currencyRate) {

function showMyPayouts({day, hour}, currencyRate) {
document.getElementById('my_payouts_1h').textContent = parseFloat(hour.amount).toFixed(8)
document.getElementById('my_payouts_1h_usd').textContent = amountUSD(hour.amount, currencyRate.rate)
document.getElementById('my_payouts_1h_usd').textContent = amountUSD(hour.amount, currencyRate)

document.getElementById('my_payouts_24h').textContent = parseFloat(day.amount).toFixed(8)
document.getElementById('my_payouts_24h_usd').textContent = amountUSD(day.amount, currencyRate.rate)
document.getElementById('my_payouts_24h_usd').textContent = amountUSD(day.amount, currencyRate)
}


function showMyBalance(myBalanceData, currencyRate) {
document.getElementById('balance').textContent = parseFloat(myBalanceData.amount).toFixed(8)
document.getElementById('balance_usd').textContent = amountUSD(myBalanceData.amount, currencyRate.rate)
document.getElementById('balance_usd').textContent = amountUSD(myBalanceData.amount, currencyRate)
}

function showPayoutsTable(payouts) {
Expand All @@ -124,11 +124,11 @@ function showEventsTable(events) {
tableBody.innerHTML = '';

events.forEach((event) => {
const row = tableBody.insertRow();
row.insertCell(0).textContent = event.worker ?? 'N/A';
row.insertCell(1).textContent = event.message;
row.insertCell(2).textContent = event.count;
row.insertCell(3).textContent = new Date(event.latest).toLocaleString();
const row = tableBody.insertRow();
row.insertCell(0).textContent = event.worker ?? 'N/A';
row.insertCell(1).textContent = event.message;
row.insertCell(2).textContent = event.count;
row.insertCell(3).textContent = new Date(event.latest).toLocaleString();
});
}

Expand Down Expand Up @@ -170,9 +170,9 @@ function drawData(wallet) {
day: {hashrate: hashrate24h, units: hashrate1hResponse.units}
});
showWorkersTable(hashrate1hResponse.workers, hashrate24hResponse.workers);
showMyPayouts({hour: {amount: payouts1h}, day: {amount: payouts24h}}, currencyRate);
showMyPayouts({hour: {amount: payouts1h}, day: {amount: payouts24h}}, currencyRate.rate.value);
showPayoutsTable(payouts24hResponse.payouts)
showMyBalance(myBalanceResponse, currencyRate);
showMyBalance(myBalanceResponse, currencyRate.rate.value);
showEventsTable(myEventsResponse.events);
showStats();
enableButton();
Expand Down Expand Up @@ -238,19 +238,20 @@ function assignFormListener() {


function switchTab(event, tabId) {
document.querySelectorAll('.tab').forEach(tab => {
tab.classList.remove('active')
})

document.querySelectorAll('.tab-links .button').forEach(tab => {
tab.classList.remove('button-outline')
tab.classList.add('button-clear')
})

document.getElementById(tabId).classList.add('active')
event.currentTarget.classList.add('button-outline')
event.currentTarget.classList.remove('button-clear')
document.querySelectorAll('.tab').forEach(tab => {
tab.classList.remove('active')
})

document.querySelectorAll('.tab-links .button').forEach(tab => {
tab.classList.remove('button-outline')
tab.classList.add('button-clear')
})

document.getElementById(tabId).classList.add('active')
event.currentTarget.classList.add('button-outline')
event.currentTarget.classList.remove('button-clear')
}

function init() {
assignFormListener();

Expand Down

0 comments on commit 23bc9a8

Please # to comment.