From 2110e2e1f490bb2c492eba87ff52d330482ca3b8 Mon Sep 17 00:00:00 2001 From: gonefishing4422 <119458070+gonefishing4422@users.noreply.github.com> Date: Thu, 4 Jan 2024 17:58:27 -0600 Subject: [PATCH] add content --- js/getblockmns.js | 48 ++++ masternodes.html | 701 ++++++++++++++++++++++------------------------ 2 files changed, 378 insertions(+), 371 deletions(-) diff --git a/js/getblockmns.js b/js/getblockmns.js index 0654eea..1c1c80c 100644 --- a/js/getblockmns.js +++ b/js/getblockmns.js @@ -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'); @@ -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(); }) @@ -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); +}); diff --git a/masternodes.html b/masternodes.html index 3383cf9..fccc833 100644 --- a/masternodes.html +++ b/masternodes.html @@ -1,383 +1,342 @@ - - -
- - - - - -