<script>
// Function to fetch mining stats
function fetchMiningStats() {
const input = document.getElementById('wallet-input').value.trim();
if (input.length > 25) {
fetchMiningStatsForWallet(input);
} else {
fetchWorker(input);
}
}
// Function to fetch mining stats for a wallet address
function fetchMiningStatsForWallet(walletAddress) {
const url = `https://api.codetabs.com/v1/proxy/?quest=http://pool.ergo-sig-mining.net:4000/api/pools/ErgoSigmanauts/miners/${walletAddress}`;
fetchAndDisplayStats(url);
}
// Function to fetch the list of workers and their associated wallet addresses
function fetchWorker(workerName) {
const apiUrl = 'https://api.codetabs.com/v1/proxy/?quest=http://pool.ergo-sig-mining.net:4000/api/pools/ErgoSigmanauts/miners/';
fetch(apiUrl)
.then(response => response.json())
.then(data => {
let found = false;
data.forEach(miner => {
const minerAddress = miner.miner.replace('"', '').replace('"', ''); // Extract the miner address
const url = `https://api.codetabs.com/v1/proxy/?quest=http://pool.ergo-sig-mining.net:4000/api/pools/ErgoSigmanauts/miners/${minerAddress}`;
fetchAndCheckWorker(url, workerName);
});
})
.catch(error => {
console.error('Error fetching worker list:', error);
alert('Error fetching worker list. Please try again later.');
});
}
// Function to fetch mining stats and check for the worker name
function fetchAndCheckWorker(url, workerName) {
fetch(url)
.then(response => response.json())
.then(stats => {
const workers = Object.keys(stats.performance.workers);
if (workers.includes(workerName)) {
displayStats(stats);
}
})
.catch(error => {
console.error('Error fetching mining stats:', error);
});
}
// Function to fetch mining stats and display them
function fetchAndDisplayStats(url) {
fetch(url)
.then(response => response.json())
.then(stats => {
displayStats(stats);
})
.catch(error => {
console.error('Error fetching mining stats:', error);
alert('Error fetching mining stats. Please try again later.');
});
}
// Function to display mining stats
function displayStats(stats) {
const miningStatsElement = document.getElementById('mining-stats');
miningStatsElement.innerHTML = `
<h2>Worker Stats</h2>
${Object.entries(stats.performance.workers).map(([workerName, workerData]) => `
<h3>${workerName}</h3>
Hashrate: ${formatHashrate(workerData.hashrate)}<br>
Shares Per Second: ${workerData.sharesPerSecond}<br>
`).join('')}
<h2>Summary</h2>
Last Payment: ${stats.lastPayment}<br>
Pending Balance: ${stats.pendingBalance}<br>
Pending Shares: ${stats.pendingShares}<br>
`;
}
// Function to format hashrate
function formatHashrate(hashrate) {
if (hashrate >= 1000000000) {
return `${(hashrate / 1000000000).toFixed(1)} GH/s`;
} else {
return `${(hashrate / 1000000).toFixed(1)} MH/s`;
}
}
// Function to save user input to localStorage
function saveInput() {
const userInput = document.getElementById("wallet-input").value;
localStorage.setItem("lastInput", userInput);
}
// Function to load last input from localStorage
function loadLastInput() {
const lastInput = localStorage.getItem("lastInput");
if (lastInput) {
document.getElementById("wallet-input").value = lastInput;
fetchMiningStats(); // Automatically fetch stats based on the saved input
}
}
// Load last input when the page loads
window.onload = function() {
loadLastInput();
}
// Refresh the page every 2 minutes
setInterval(function() {
fetchMiningStats(); // Automatically fetch stats every 2 minutes
}, 120000); // 2 minutes in milliseconds
</script>
sigmining's Introduction
sigmining's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.