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

Commit

Permalink
add content
Browse files Browse the repository at this point in the history
  • Loading branch information
gonefishing4422 committed Jan 4, 2024
1 parent 023c7ea commit 2110e2e
Show file tree
Hide file tree
Showing 2 changed files with 378 additions and 371 deletions.
48 changes: 48 additions & 0 deletions js/getblockmns.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
// Function to make the API call and update the DOM for mn-lock-funds
async function fetchLockFunds() {
try {
const response = await fetch('https://api.nosocoin.com/info/locked_supply');
const mnLockFunds = await response.text();

if (!isNaN(mnLockFunds)) {
document.getElementById('mn-lock-funds').innerText = mnLockFunds;
return mnLockFunds;
} else {
throw new Error('mn-lock-funds data not a valid number.');
}
} catch (error) {
console.error('Error fetching mn-lock-funds:', error);
}
}

// Function to calculate and display mn-lock-count
function displayLockCount(mnLockFunds) {
const mnLockCount = mnLockFunds / 10500;
document.getElementById('mn-lock-count').innerText = mnLockCount;
}

// Function to calculate and display mn-inactive-nodes
function calculateInactiveNodes(mnLockCount, nodeCount) {
const mnInactiveNodes = mnLockCount - nodeCount;
document.getElementById('mn-inactive-nodes').innerText = mnInactiveNodes;
}

// Call the functions when the page loads
fetchLockFunds().then(mnLockFunds => {
// Call the lock count function after fetching mn-lock-funds
if (!isNaN(mnLockFunds)) {
displayLockCount(mnLockFunds);
}
});

document.addEventListener("DOMContentLoaded", function () {
const urlParams = new URLSearchParams(window.location.search);
let blockHeight = urlParams.get('blockheight');
Expand Down Expand Up @@ -94,6 +131,10 @@ document.addEventListener("DOMContentLoaded", function () {
const earningPercentage = (totalReward / (totalReward * activeNodes)) * 100;
document.getElementById('earning-percentage').textContent = earningPercentage.toFixed(2) + '%';

// Call the function to calculate and display mn-inactive-nodes
const mnLockCount = parseFloat(document.getElementById('mn-lock-count').innerText);
calculateInactiveNodes(mnLockCount, nodeCount);

// Call the function to fetch data for the line chart
fetchBlockDataForChart();
})
Expand Down Expand Up @@ -264,3 +305,10 @@ document.addEventListener("DOMContentLoaded", function () {
.catch(error => console.error(error));
}
});

// Function to calculate and display mn-inactive-nodes
document.addEventListener("DOMContentLoaded", function () {
const mnLockCount = parseFloat(document.getElementById('mn-lock-count').innerText);
const nodeCount = parseFloat(document.getElementById('node-count').innerText);
calculateInactiveNodes(mnLockCount, nodeCount);
});
Loading

0 comments on commit 2110e2e

Please sign in to comment.