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

Commit

Permalink
fix some formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
gonefishing4422 committed Jan 4, 2024
1 parent 713b095 commit 023c7ea
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 75 deletions.
2 changes: 1 addition & 1 deletion getearnings.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
reporting Masternode earnings may take some time. Please
be patient.  Search multiple Masternode addresses
simultaneously separating each with a comma (,)
(address1,address2),address3).</p>
(address1,address2,address3).</p>
<br></div>
<div class="search1-wrapper"> <input id="addresses" name="addresses"

Expand Down
148 changes: 76 additions & 72 deletions js/getblockmns.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,17 @@
document.addEventListener("DOMContentLoaded", function () {
// Initial fetch to get the currentHeight
fetch('https://api.nosostats.com:8078', {
method: 'POST',
headers: {
'Origin': 'https://api.nosostats.com'
},
body: JSON.stringify({
"jsonrpc": "2.0",
"method": "getmainnetinfo",
"params": [],
"id": 9
})
})
.then(response => response.json())
.then(data => {
const currentHeight = data.result[0].lastblock;
if (!blockHeight) {
blockHeight = currentHeight;
urlParams.set('blockheight', blockHeight);
const newUrl = `${window.location.origin}${window.location.pathname}?${urlParams.toString()}`;
window.history.replaceState(null, '', newUrl);
}

fetchDataForBlockHeight(blockHeight);
})
.catch(error => console.error(error));


const urlParams = new URLSearchParams(window.location.search);
let blockHeight = urlParams.get('blockheight');
const urlParams = new URLSearchParams(window.location.search);
let blockHeight = urlParams.get('blockheight');

// Function to update the URL with the new blockHeight value
function updateURL(newBlockHeight) {
urlParams.set('blockheight', newBlockHeight);
const newUrl = `${window.location.origin}${window.location.pathname}?${urlParams.toString()}`;
window.history.replaceState(null, '', newUrl);
}
// Function to update the URL with the new blockHeight value
function updateURL(newBlockHeight) {
urlParams.set('blockheight', newBlockHeight);
const newUrl = `${window.location.origin}${window.location.pathname}?${urlParams.toString()}`;
window.history.replaceState(null, '', newUrl);
}

// Function to fetch data for a specific blockHeight
function fetchDataForBlockHeight(blockHeight) {
const getsupply = document.getElementById('getsupply');
const getsupply = document.getElementById('getsupply');
fetch('https://api.nosostats.com:8078', {
method: 'POST',
headers: {
Expand Down Expand Up @@ -104,42 +76,32 @@ function updateURL(newBlockHeight) {
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);

// Blockheight
var blockheightElement = document.getElementById('blockheight');
var blockheightLink = document.createElement("a");
blockheightLink.href = "getblockinfo.html?blockheight=" + blockHeight;
blockheightLink.textContent = blockHeight;
blockheightElement.appendChild(blockheightLink);

// Node Locked Funds
// Blockheight
var blockheightElement = document.getElementById('blockheight');
var blockheightLink = document.createElement("a");
blockheightLink.href = "getblockinfo.html?blockheight=" + blockHeight;
blockheightLink.textContent = blockHeight;
blockheightElement.appendChild(blockheightLink);

// Node Locked Funds
const nodeCount = data.result[0].count;
document.getElementById('node-funds-locked').textContent = parseInt(nodeCount * 10500);


// Calculate and set the earning-percentage
const totalReward = parseFloat(data.result[0].total * 0.00000001);
const activeNodes = parseInt(data.result[0].count);
const earningPercentage = (totalReward / (totalReward * activeNodes)) * 100;
document.getElementById('earning-percentage').textContent = earningPercentage.toFixed(2) + '%';

// Call the function to fetch data for the line chart
fetchBlockDataForChart();
})
.catch(error => console.error(error));
}

// Handle the "Back" button click
document.getElementById('backButton').addEventListener('click', () => {
if (blockHeight) {
blockHeight = Math.max(1, parseInt(blockHeight) - 1); // Ensure it doesn't go lower than 1
updateURL(blockHeight);
fetchDataForBlockHeight(blockHeight);
location.reload();
}
});

// Handle the "Forward" button click
document.getElementById('forwardButton').addEventListener('click', () => {
if (blockHeight) {
// Fetch the current height
// Fetch the currentHeight if blockHeight is not available
if (!blockHeight) {
fetch('https://api.nosostats.com:8078', {
method: 'POST',
headers: {
Expand All @@ -155,17 +117,62 @@ document.getElementById('forwardButton').addEventListener('click', () => {
.then(response => response.json())
.then(data => {
const currentHeight = data.result[0].lastblock;

if (blockHeight < currentHeight) {
blockHeight = parseInt(blockHeight) + 1;
updateURL(blockHeight);
fetchDataForBlockHeight(blockHeight);
location.reload();
}
blockHeight = currentHeight;
updateURL(blockHeight);
fetchDataForBlockHeight(blockHeight);
})
.catch(error => console.error(error));
} else {
// If blockHeight is available in the URL, directly fetch data
fetchDataForBlockHeight(blockHeight);
}
});

// Handle the "Back" button click
document.getElementById('backButton').addEventListener('click', () => {
if (blockHeight) {
blockHeight = Math.max(1, parseInt(blockHeight) - 1); // Ensure it doesn't go lower than 1
updateURL(blockHeight);
fetchDataForBlockHeight(blockHeight);
location.reload();
}
});

// Handle the "Forward" button click
document.getElementById('forwardButton').addEventListener('click', () => {
if (blockHeight) {
// Fetch the current height
fetch('https://api.nosostats.com:8078', {
method: 'POST',
headers: {
'Origin': 'https://api.nosostats.com'
},
body: JSON.stringify({
"jsonrpc": "2.0",
"method": "getmainnetinfo",
"params": [],
"id": 9
})
})
.then(response => response.json())
.then(data => {
const currentHeight = data.result[0].lastblock;

if (blockHeight < currentHeight) {
blockHeight = parseInt(blockHeight) + 1;
updateURL(blockHeight);
fetchDataForBlockHeight(blockHeight);
location.reload();
}
})
.catch(error => console.error(error));
}
});

// Handle popstate event to fetch and update data when the back/forward button is clicked
window.addEventListener('popstate', function () {
blockHeight = urlParams.get('blockheight');
fetchDataForBlockHeight(blockHeight);
});

// Function to fetch data for the past 150 blocks in increments of 10
function fetchBlockDataForChart() {
Expand Down Expand Up @@ -256,7 +263,4 @@ document.getElementById('forwardButton').addEventListener('click', () => {
})
.catch(error => console.error(error));
}

// Call the function to fetch data for the line chart
fetchBlockDataForChart();
});
});
6 changes: 4 additions & 2 deletions masternodes.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@

src="img/node.png" style="width: 24px; height: 18px;">&nbsp;<a

href="getearnings.html">Check&nbsp;your&nbsp;MasterNode&nbsp;Earnings</a>&nbsp;<img src="img/mbag.png" style="width: 24px; height: 18px;"></p>
href="getearnings.html">Check&nbsp;your&nbsp;MasterNode&nbsp;Earnings</a>&nbsp;<img

src="img/mbag.png" style="width: 24px; height: 18px;"></p>
<br>
<p class="announcement-text" style="width: 200px;"><font

Expand Down Expand Up @@ -300,7 +302,7 @@
<div class="panel-head-tiles">
<div class="row" id="refresh">
<div class="row2">
<p class="announcement-text" style="width: 100px;"><font
<p class="announcement-text" style="width: 200px;"><font

size="2px" color="white"> <br>
Masternodes paid in this block: <br>
Expand Down

0 comments on commit 023c7ea

Please sign in to comment.