Skip to content
This repository has been archived by the owner on Sep 14, 2024. It is now read-only.

Commit

Permalink
Add content to masternodes page
Browse files Browse the repository at this point in the history
  • Loading branch information
gonefishing4422 committed Jan 11, 2024
1 parent 5673498 commit 87a3daf
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 20 deletions.
91 changes: 88 additions & 3 deletions js/getblockmns.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
async function fetchNosoCoinData() {
try {
const response = await fetch("https://api.nosocoin.com/info/price?range=day&interval=1");

if (response.ok) {
const result = await response.json();
return result;
} else {
throw new Error("NosoCoin API request failed");
}
} catch (error) {
console.error("Error fetching NosoCoin data:", error);
return null;
}
}

async function fetchBTCValue() {
try {
const response = await fetch('https://tradeogre.com/api/v1/markets');
if (response.ok) {
const data = await response.json();
const btcUsdtAsk = data.find(market => market.hasOwnProperty("BTC-USDT"))["BTC-USDT"]["ask"];
return btcUsdtAsk;
} else {
throw new Error("BTC value fetch request failed");
}
} catch (error) {
console.error("Error fetching BTC value:", error);
return null;
}
}

async function displayData() {
const nosoUsdtLastPriceElement = document.getElementById("noso-usdt-lastPrice");
const nosoBtcLastPriceElement = document.getElementById("noso-btc-lastPrice");

const nosoCoinData = await fetchNosoCoinData();
if (nosoCoinData && nosoCoinData.length > 0) {
const lastDataPoint = nosoCoinData[nosoCoinData.length - 1];
const nosoUsdtLastPrice = lastDataPoint.price.toFixed(2); // Round to two decimal places
nosoUsdtLastPriceElement.textContent = nosoUsdtLastPrice;

const btcValue = await fetchBTCValue();
if (btcValue) {
const nosoValueInUsdt = lastDataPoint.price; // Use the obtained Noso value
const nosoToBtcValue = (nosoValueInUsdt / btcValue).toFixed(8); // Round to eight decimal places
nosoBtcLastPriceElement.textContent = nosoToBtcValue;
} else {
nosoBtcLastPriceElement.textContent = "Failed to calculate Noso to BTC value.";
}
} else {
nosoUsdtLastPriceElement.textContent = "API Unavailable.";
nosoBtcLastPriceElement.textContent = "";
}
}

displayData();
// Function to make the API call and update the DOM for mn-lock-funds
async function fetchLockFunds() {
try {
Expand Down Expand Up @@ -116,9 +173,10 @@ document.addEventListener("DOMContentLoaded", function () {
document.getElementById('total-reward').textContent = (data.result[0].total * 0.00000001).toFixed(8);
document.getElementById('node-count').textContent = data.result[0].count;
document.getElementById('node-reward').textContent = (data.result[0].reward * 0.00000001).toFixed(8);
document.getElementById('node-24hr-reward').textContent = (data.result[0].reward * 0.00000001 * 144).toFixed(8);
document.getElementById('node-7day-reward').textContent = (data.result[0].reward * 0.00000001 * 1008).toFixed(8);
document.getElementById('node-30day-reward').textContent = (data.result[0].reward * 0.00000001 * 4320).toFixed(8);
document.getElementById('node-24hr-reward').textContent = (data.result[0].reward * 0.00000001 * 144).toFixed(0);
document.getElementById('node-7day-reward').textContent = (data.result[0].reward * 0.00000001 * 1008).toFixed(0);
document.getElementById('node-30day-reward').textContent = (data.result[0].reward * 0.00000001 * 4320).toFixed(0);
document.getElementById('node-365day-reward').textContent = (data.result[0].reward * 0.00000001 * 52560).toFixed(0);

// Blockheight
var blockheightElement = document.getElementById('blockheight');
Expand All @@ -143,10 +201,37 @@ document.addEventListener("DOMContentLoaded", function () {

// Call the function to fetch data for the line chart
fetchBlockDataForChart();
// Calculate node rewards in USDT and BTC
const nosoUsdtLastPriceElement = document.getElementById('noso-usdt-lastPrice');
const nosoBtcLastPriceElement = document.getElementById('noso-btc-lastPrice');

if (nosoUsdtLastPriceElement && nosoBtcLastPriceElement) {
const nosoUsdtLastPrice = parseFloat(nosoUsdtLastPriceElement.textContent);
const nosoBtcLastPrice = parseFloat(nosoBtcLastPriceElement.textContent);

const reward = data.result[0].reward * 0.00000001;

document.getElementById('node-24hr-reward-usdt').textContent = (reward * 144 * nosoUsdtLastPrice).toFixed(2);
document.getElementById('node-7day-reward-usdt').textContent = (reward * 1008 * nosoUsdtLastPrice).toFixed(2);
document.getElementById('node-30day-reward-usdt').textContent = (reward * 4320 * nosoUsdtLastPrice).toFixed(2);
document.getElementById('node-365day-reward-usdt').textContent = (reward * 52560 * nosoUsdtLastPrice).toFixed(2);
document.getElementById('node-value-usdt').textContent = (10500 * nosoUsdtLastPrice).toFixed(2);

document.getElementById('node-24hr-reward-btc').textContent = (reward * 144 * nosoBtcLastPrice).toFixed(8);
document.getElementById('node-7day-reward-btc').textContent = (reward * 1008 * nosoBtcLastPrice).toFixed(8);
document.getElementById('node-30day-reward-btc').textContent = (reward * 4320 * nosoBtcLastPrice).toFixed(8);
document.getElementById('node-365day-reward-btc').textContent = (reward * 52560 * nosoBtcLastPrice).toFixed(8);
document.getElementById('node-value-btc').textContent = (10500 * nosoBtcLastPrice).toFixed(8);
} else {
console.error("Elements 'noso-usdt-lastPrice' or 'noso-btc-lastPrice' not found.");
}
})
.catch(error => console.error(error));

}



// Fetch the currentHeight if blockHeight is not available
if (!blockHeight) {
fetch('https://api.nosostats.com:8078', {
Expand Down
45 changes: 28 additions & 17 deletions masternodes.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
<div class="row">
<div class="col-lg-12">
<div class="row2">
<!---testing--->
<!---BEGIN--->
<div class="col-lg-6">
<div class="panel panel-info">
<div class="panel-head-tiles">
Expand Down Expand Up @@ -178,7 +178,7 @@
</div>
</div>
</div>
<!---chart-->
<!---chart--><br><br>
<div class="col-lg-12">
<div class="panel panel-info">
<div class="panel-head-tiles">
Expand All @@ -204,20 +204,31 @@
<div class="panel panel-info">
<div class="panel-head-tiles">
<div class="row">
<p class="announcement-text" style="width: 200px;"><strong><font
size="2px" color="fbe04d">Node Estimated
Earnings</font></strong></p>
<br>
<p class="mn-announcement-text" style="width: 250px;">Estimated
24 Hour Reward:&nbsp;<font size="2px" color="white"><span
id="node-24hr-reward">0</span></font></p>
<p class="mn-announcement-text" style="width: 250px;">Estimated
7 Day Reward:&nbsp;<font size="2px" color="white"><span
id="node-7day-reward">0</span></font></p>
<p class="mn-announcement-text" style="width: 250px;">Estimated
30 Day Reward:&nbsp;<font size="2px" color="white"><span
id="node-30day-reward">0</span></font></p>
<br>

<p class="mn-announcement-text" ><strong><font size="2px" color="#fbe04d">Price: $<span id="noso-usdt-lastPrice">0</span>&nbsp;/&nbsp;<span id="noso-btc-lastPrice">0</span> BTC</font></strong>
<p class="mn-announcement-text" style="width: 250px;><strong><font size="2px" color="grey">Node reward frequency: </font><font size="2px" color="grey">10&nbsp;Minutes</font></strong>
<p class="mn-announcement-text" style="width: 250px;><strong><font size="2px" color="gray">Required Coins for Node: </font><font size="2px" color="grey">10,500 NOSO</font></strong>
<p class="mn-announcement-text" style="width: 250px;> <strong><font size="2px" color="grey">Node Value:</font><font size="2px" color="grey">$<span id="node-value-usdt">0</span>&nbsp;/&nbsp;<span id="node-value-btc">0</span> BTC</font></strong>

<hr style="border: 1px solid #222222; size="2" width="100%" noshade align="left" /></p>

<p class="mn-announcement-text" style="width: 250px;"><strong><font size="2px" color="#fbe04d">Estimated Daily Income&nbsp;</strong></font></p>
<p class="mn-announcement-text" style="width: 250px;"><font size="2px" color="grey">$<span id="node-24hr-reward-usdt">0</span>&nbsp;</font></p>
<p class="mn-announcement-text" style="width: 250px;"><font size="2px" color="grey"><span id="node-24hr-reward-btc">0</span>&nbsp;BTC</font></p>
<p class="mn-announcement-text" style="width: 250px;"><strong><font size="2px" color="grey"><span id="node-24hr-reward">0</span></font><font size="2px" color="grey">&nbsp;NOSO</font></strong></p>
<p class="mn-announcement-text" style="width: 250px;"><strong><font size="2px" color="#fbe04d">Estimated Weekly Income&nbsp;</strong></font></p>
<p class="mn-announcement-text" style="width: 250px;"><font size="2px" color="grey">$<span id="node-7day-reward-usdt">0</span>&nbsp;</font></p>
<p class="mn-announcement-text" style="width: 250px;"><font size="2px" color="grey"><span id="node-7day-reward-btc">0</span>&nbsp;BTC</font></p>
<p class="mn-announcement-text" style="width: 250px;"><strong><font size="2px" color="grey"><span id="node-7day-reward">0</span></font><font size="2px" color="grey">&nbsp;NOSO</font></strong></p>
<p class="mn-announcement-text" style="width: 250px;"><strong><font size="2px" color="#fbe04d">Estimated Monthly Income&nbsp;</strong></font></p>
<p class="mn-announcement-text" style="width: 250px;"><font size="2px" color="grey">$<span id="node-30day-reward-usdt">0</span>&nbsp;</font></p>
<p class="mn-announcement-text" style="width: 250px;"><font size="2px" color="grey"><span id="node-30day-reward-btc">0</span>&nbsp;BTC</font></p>
<p class="mn-announcement-text" style="width: 250px;"><strong><font size="2px" color="grey"><span id="node-30day-reward">0</span></font><font size="2px" color="grey">&nbsp;NOSO</font></strong></p>
<p class="mn-announcement-text" style="width: 250px;"><strong><font size="2px" color="#fbe04d">Estimated Yearly Income&nbsp;</strong></font></p>
<p class="mn-announcement-text" style="width: 250px;"><font size="2px" color="grey">$<span id="node-365day-reward-usdt">0</span>&nbsp;</font></p>
<p class="mn-announcement-text" style="width: 250px;"><font size="2px" color="grey"><span id="node-365day-reward-btc">0</span>&nbsp;BTC</font></p>
<p class="mn-announcement-text" style="width: 250px;"><strong><font size="2px" color="grey"><span id="node-365day-reward">0</span></font><font size="2px" color="grey">&nbsp;NOSO</font></strong></p>

</div>
</div>
</div>
Expand Down Expand Up @@ -253,7 +264,7 @@
</div>
</div>
</div>
<!---testing---> </div>
<!---END---> </div>
</div>
<div class="row">
<div class="col-lg-12">
Expand Down

0 comments on commit 87a3daf

Please sign in to comment.