wownero-puddle/src/webui-embed.html

117 lines
4.4 KiB
HTML
Raw Normal View History

2018-08-12 13:46:08 +00:00
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: "Courier New", Courier, monospace;
}
header {
font-size: larger;
font-weight: bold;
padding-bottom: 1em;
}
.wallet {
display: none;
}
</style>
</head>
<body>
<header>THE Monero Mining Pool</header>
<table>
2019-03-03 20:26:11 +00:00
<tr><td>Pool HR: </td><td id="pool_hashrate"></td></tr>
<tr><td>Network HR: </td><td id="network_hashrate"></td></tr>
<tr><td>Blocks found: </td><td id="pool_blocks_found"></td></tr>
<tr><td>Last block found: </td><td id="last_block_found"></td></tr>
<tr><td>Payment threshold: </td><td id="payment_threshold"></td></tr>
<tr><td>Pool fee: </td><td id="pool_fee"></td></tr>
<tr><td>Pool port: </td><td id="pool_port"></td></tr>
<tr><td>Miners connected: </td><td id="connected_miners"></td></tr>
<tr class="wallet"><td>Your HR: </td><td id="miner_hashrate"></td></tr>
<tr class="wallet"><td>Balance due: </td><td id="miner_balance"></td></tr>
2018-08-12 13:46:08 +00:00
</table>
<form>
Your wallet address: <input type="text" id="wa" name="address" />
<input type="submit" value="Submit" />
</form>
<script>
2019-03-03 20:26:11 +00:00
function format_last_block(last)
{
var now = new Date().getTime() / 1000;
var diff = now - last;
if (last == 0)
return "None yet";
else if (diff < 60)
return parseInt(diff) + " seconds ago";
else if (diff < 3600)
return parseInt(diff/60) + " minutes ago";
else if (diff < 86400)
return parseInt(diff/3600) + " hours ago";
else
return parseInt(diff/86400) + " days ago";
}
function format_hashrate(hr)
{
if (hr < 1000)
return parseInt(hr) + " H/s";
else if (hr < 1000000)
return parseFloat(hr/1000).toFixed(2) + " KH/s";
else if (hr < 1000000000000)
return parseFloat(hr/1000000).toFixed(2) + " MH/s";
else
return parseFloat(hr/1000000000000).toFixed(2) + " GH/s";
}
var xhr = new XMLHttpRequest();
xhr.onload = function()
{
var stats = JSON.parse(xhr.responseText);
for (var e in stats)
{
var el = document.querySelector("#"+e);
if (e == "last_block_found")
el.innerHTML = format_last_block(stats[e]);
else if (/hashrate/.test(e))
el.innerHTML = format_hashrate(stats[e]);
else
el.innerHTML = stats[e];
}
};
2018-08-12 13:46:08 +00:00
var f = document.querySelector("form");
var wa = document.querySelector("#wa");
f.onsubmit = function(e)
{
e.preventDefault();
var d = new Date();
d.setTime(d.getTime() + (86400 * 365 * 1000));
document.cookie = "wa=" + wa.value + ";expires=" + d.toGMTString();
window.location.reload();
return false;
};
window.onload = function()
{
if (/wa=[0-9a-fA-F]+/.test(document.cookie))
{
var wh = document.querySelectorAll(".wallet");
wh.forEach(function(e)
{
e.style = "display: table-row;";
});
var c = document.cookie.split("=");
wa.value = c[1];
}
2019-03-07 22:17:11 +00:00
var get_stats = function()
2018-08-12 13:46:08 +00:00
{
2019-03-07 22:17:11 +00:00
xhr.open("GET", "/stats");
2019-03-03 20:26:11 +00:00
xhr.send(null);
2019-03-07 22:17:11 +00:00
};
setInterval(get_stats, 30000);
get_stats();
2018-08-12 13:46:08 +00:00
};
</script>
</body>
</html>