add minor formatting improvements

This commit is contained in:
Jethro Grassie 2020-01-18 16:05:34 -05:00
parent 18ce80693a
commit d80390c0fb
No known key found for this signature in database
GPG Key ID: DE8ED755616565BB
2 changed files with 29 additions and 19 deletions

View File

@ -1585,7 +1585,7 @@ startup_scan_round_shares()
} }
static int static int
startup_pauout(uint64_t height) startup_payout(uint64_t height)
{ {
/* /*
Loop stored blocks < height - 60 Loop stored blocks < height - 60
@ -1714,7 +1714,7 @@ rpc_on_last_block_header(const char* data, rpc_callback_t *callback)
{ {
block_t *block = bstack_push(bsh, NULL); block_t *block = bstack_push(bsh, NULL);
response_to_block(block_header, block); response_to_block(block_header, block);
startup_pauout(block->height); startup_payout(block->height);
startup_scan_round_shares(); startup_scan_round_shares();
need_new_template = true; need_new_template = true;
} }

View File

@ -26,7 +26,7 @@
.miner { .miner {
display: none; display: none;
} }
td.address { #address {
min-width: 10ch; min-width: 10ch;
max-width: 10ch; max-width: 10ch;
overflow: hidden; overflow: hidden;
@ -35,7 +35,7 @@
white-space: nowrap; white-space: nowrap;
word-wrap: unset; word-wrap: unset;
} }
td.address:focus { #address:focus {
outline: 0px solid transparent; outline: 0px solid transparent;
text-overflow: initial; text-overflow: initial;
white-space: initial; white-space: initial;
@ -62,7 +62,7 @@
<tr><td>Miners connected: </td><td id="connected_miners"></td></tr> <tr><td>Miners connected: </td><td id="connected_miners"></td></tr>
<tr class="miner"><td>Your HR: </td><td id="miner_hashrate"></td></tr> <tr class="miner"><td>Your HR: </td><td id="miner_hashrate"></td></tr>
<tr class="miner"><td>Balance due: </td><td id="miner_balance"></td></tr> <tr class="miner"><td>Balance due: </td><td id="miner_balance"></td></tr>
<tr><td>Miner address: </td><td class="address" contenteditable="true"></td></tr> <tr><td>Miner address: </td><td id="address" contenteditable="true"></td></tr>
</table> </table>
<small><a href="https://github.com/jtgrassie/monero-pool">https://github.com/jtgrassie/monero-pool</a></small> <small><a href="https://github.com/jtgrassie/monero-pool">https://github.com/jtgrassie/monero-pool</a></small>
<script> <script>
@ -95,26 +95,31 @@
} }
} }
function max_precision(n, p)
{
return parseFloat(parseFloat(n).toFixed(p));
}
function format_hashes(h) function format_hashes(h)
{ {
if (h < 1e-12) if (h < 1e-12)
return "0 H"; return "0 H";
else if (h < 1e-9) else if (h < 1e-9)
return parseFloat(h*1e+12).toFixed(2) + " pH"; return max_precision(h*1e+12, 0) + " pH";
else if (h < 1e-6) else if (h < 1e-6)
return parseFloat(h*1e+9).toFixed(2) + " nH"; return max_precision(h*1e+9, 0) + " nH";
else if (h < 1e-3) else if (h < 1e-3)
return parseFloat(h*1e+6).toFixed(2) + " μH"; return max_precision(h*1e+6, 0) + " μH";
else if (h < 1) else if (h < 1)
return parseFloat(h*1e+3).toFixed(2) + " mH"; return max_precision(h*1e+3, 0) + " mH";
else if (h < 1e+3) else if (h < 1e+3)
return parseInt(h) + " H"; return parseInt(h) + " H";
else if (h < 1e+6) else if (h < 1e+6)
return parseFloat(h*1e-3).toFixed(2) + " KH"; return max_precision(h*1e-3, 2) + " KH";
else if (h < 1e+9) else if (h < 1e+9)
return parseFloat(h*1e-6).toFixed(2) + " MH"; return max_precision(h*1e-6, 2) + " MH";
else else
return parseFloat(h*1e-9).toFixed(2) + " GH"; return max_precision(h*1e-9, 2) + " GH";
} }
function format_hashrate(h) function format_hashrate(h)
@ -130,11 +135,12 @@
return 0; return 0;
if (diff <= 0) if (diff <= 0)
return 0; return 0;
return format_hashrate(round_hashes / diff) return format_hashrate(round_hashes / diff);
} }
var wf = document.querySelector(".address"); var wf = document.querySelector("#address");
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
var rhr = document.querySelector("#round_hashrate");
xhr.onload = function() xhr.onload = function()
{ {
@ -144,7 +150,7 @@
var el = document.querySelector("#"+e); var el = document.querySelector("#"+e);
if (!el) if (!el)
continue; continue;
if (e == "last_block_found" || e == "last_template_fetched") if (/^last/.test(e))
el.innerHTML = format_last_time(stats[e]); el.innerHTML = format_last_time(stats[e]);
else if (/hashrate/.test(e)) else if (/hashrate/.test(e))
el.innerHTML = format_hashrate(stats[e]); el.innerHTML = format_hashrate(stats[e]);
@ -154,9 +160,12 @@
el.innerHTML = stats[e] == 1 ? "Yes" : "No"; el.innerHTML = stats[e] == 1 ? "Yes" : "No";
else if (e == "round_hashes") else if (e == "round_hashes")
{ {
el.innerHTML = (stats[e]*100/stats["network_difficulty"]).toFixed(2) + "%" el.innerHTML = max_precision(stats[e]*100 /
el.innerHTML += " (" + format_hashes(stats[e]) + " / " + format_hashes(stats["network_difficulty"]) + ")"; stats["network_difficulty"], 1) + "%" +
document.querySelector("#round_hashrate").innerHTML = format_round_hashrate(stats["round_hashes"], stats["last_block_found"]); " (" + format_hashes(stats[e]) + " / " +
format_hashes(stats["network_difficulty"]) + ")";
rhr.innerHTML = format_round_hashrate(
stats["round_hashes"], stats["last_block_found"]);
} }
else if (e == "pool_ssl_port") else if (e == "pool_ssl_port")
{ {
@ -173,7 +182,8 @@
{ {
var d = new Date(); var d = new Date();
d.setTime(d.getTime() + (86400 * 365 * 1000)); d.setTime(d.getTime() + (86400 * 365 * 1000));
document.cookie = "wa=" + this.innerText + ";expires=" + d.toGMTString(); document.cookie = "wa=" + this.innerText +
";expires=" + d.toGMTString();
window.location.reload(); window.location.reload();
return false; return false;
}; };