Skip to content

Commit

Permalink
Better formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
harryjph committed Jul 12, 2019
1 parent ffc368e commit 9b9e447
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/main/resources/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{TITLE>>></title>
<title>{TITLE}</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
Expand Down
39 changes: 27 additions & 12 deletions src/main/resources/html/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,32 @@ function escapeHtml(string) {

let chart = null;

function filterTimePart(part, suffix) {
if (part === 0) {
part = null;
} else {
part = part.toString() + suffix;
}
return part;
}

function formatTime(secs) {
const sec_num = parseInt(secs, 10);
const hours = Math.floor(sec_num / 3600);
const minutes = Math.floor(sec_num / 60) % 60;
let seconds;
seconds = sec_num % 60;

return [hours,minutes,seconds]
.map(v => v < 10 ? "0" + v : v)
.filter((v,i) => v !== "00" || i > 0)
.join(":")
secs = parseInt(secs, 10);
if (secs === null || secs < 0) return "";
if (secs === 0) return "0s";
let years = filterTimePart(Math.floor(secs / 3600 / 24 / 365), "y");
let days = filterTimePart(Math.floor((secs / 3600 / 24) % 365), "d");
let hours = filterTimePart(Math.floor((secs / 3600) % 24), "h");
let minutes = filterTimePart(Math.floor(secs / 60) % 60, "m");
let seconds = filterTimePart(secs % 60, "s");

let result = "";
if (years !== null) result += " " + years;
if (days !== null) result += " " + days;
if (hours !== null) result += " " + hours;
if (minutes !== null) result += " " + minutes;
if (seconds !== null) result += " " + seconds;
return result.substr(1);
}

function formatBaseTarget(baseTarget) {
Expand All @@ -70,11 +85,11 @@ function getPoolInfo() {
fetch("/api/getConfig").then(http => {
return http.json();
}).then(response => {
maxSubmissions = response.nAvg + response.processLag;
document.getElementById("poolName").innerText = response.poolName;
document.getElementById("poolAccount").innerHTML = formatMinerName(response.poolAccountRS, response.poolAccount, response.poolAccount, true);
document.getElementById("nAvg").innerText = response.nAvg;
document.getElementById("nMin").innerText = response.nMin;
maxSubmissions = response.nAvg + response.processLag;
document.getElementById("maxDeadline").innerText = response.maxDeadline;
document.getElementById("processLag").innerText = response.processLag + " Blocks";
document.getElementById("feeRecipient").innerText = response.feeRecipientRS;
Expand Down Expand Up @@ -180,7 +195,7 @@ function getMiners() {
return http.json();
}).then(response => {
let table = document.getElementById("miners");
table.innerHTML = "<tr><th>Miner</th><th>Current Deadline</th><th>Pending Balance</th><th>Effective Capacity</th><th>nConf (Last (nAvg + processLag) rounds)</th><th>Share</th><th>Software</th></tr>";
table.innerHTML = "<tr><th>Miner</th><th>Current Deadline</th><th>Pending Balance</th><th>Effective Capacity</th><th>Confirmed Deadlines</th><th>Share</th><th>Software</th></tr>";
for (let i = 0; i < response.miners.length; i++) {
let miner = response.miners[i];
let currentRoundDeadline = miner.currentRoundBestDeadline == null ? "" : formatTime(miner.currentRoundBestDeadline);
Expand Down

0 comments on commit 9b9e447

Please sign in to comment.