Skip to content

Commit

Permalink
Show total rewards for each node in leaderboard
Browse files Browse the repository at this point in the history
  • Loading branch information
iancoleman committed Aug 14, 2019
1 parent 4912b29 commit c10ec3f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,24 @@
border: solid 4px #F00;
}

.leaderboard .my-bid {
.leaderboard {
border-collapse: collapse;
}

.leaderboard td {
text-align: center;
}

.leaderboard th,
.leaderboard td {
padding: 10px 15px;
}

.leaderboard tr:nth-of-type(even) {
background-color: #EEE;
}

.leaderboard tr.my-bid {
background-color: rgba(255,0,255,0.3);
}

Expand Down
2 changes: 2 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ <h1>Settings</h1>
<th></th>
<th>Bid</th>
<th>Reward</th>
<th>sum(Reward)</th>
</tr>
</table>
</script>
Expand All @@ -89,6 +90,7 @@ <h1>Settings</h1>
<td class="rank"></td>
<td class="bid"></td>
<td class="reward"></td>
<td class="total"></td>
</tr>
</script>

Expand Down
4 changes: 3 additions & 1 deletion src/js/leaderboardrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ LeaderboardRow = function(reward) {
let template = document.getElementById("leaderboard-row-template").innerHTML;
container = document.createElement("table");
container.innerHTML = template;
this.el = container.querySelectorAll("*")[0];
this.el = container.querySelectorAll("tr")[0];

let rewardStr = reward.reward.toFixed(2);
let totalRewardStr = Math.round(reward.total).toLocaleString();

this.el.querySelectorAll(".rank")[0].textContent = reward.rank;
this.el.querySelectorAll(".bid")[0].textContent = reward.bid;
this.el.querySelectorAll(".reward")[0].textContent = rewardStr;
this.el.querySelectorAll(".total")[0].textContent = totalRewardStr;

if (reward.me) {
this.el.classList.add("my-bid");
Expand Down
1 change: 1 addition & 0 deletions src/js/section.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Section = function() {
rewards.push({
"bid": node.value,
"reward": reward,
"total": node.totalRewards,
"me": isMyBid,
});
}
Expand Down

0 comments on commit c10ec3f

Please sign in to comment.