Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Commit

Permalink
Highlight current user
Browse files Browse the repository at this point in the history
  • Loading branch information
aspiers committed Mar 31, 2020
1 parent 6abf37b commit 03f3c35
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions leaderboard/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function showUserResults(address) {
});
}

function showLeaderBoard() {
function showLeaderBoard(userAddress) {
// Request for top 20 addresses
$.ajax({
url: "https://api.thegraph.com/subgraphs/name/benesjan/co2ken",
Expand All @@ -73,10 +73,11 @@ function showLeaderBoard() {
</tr>`;
balances.forEach((userBalance, i) => {
let balance = (userBalance["balance"] / 1e18).toFixed(2);
let address = userBalance["id"];
content += `
<tr>
<tr${address == userAddress ? ' class="current-user"' : ''}>
<th class="userRank" align="left">${i + 1}</th>
<td class="userAddress">${userBalance['id']}</td>
<td class="userAddress">${address}</td>
<td class="userBalance" align="right">${balance}</td>
<td class="userDAI" align="right">${balance * 10}</td>
</tr>`;
Expand All @@ -98,7 +99,6 @@ $(document).ready(function () {
$("#user-dai-spent").text(totalDaiSpent);

showContractTotals();
showLeaderBoard();

window.addEventListener('dappHeroConfigLoaded', ({ detail: dappHero }) => {
if (dappHero.provider) {
Expand All @@ -107,6 +107,7 @@ $(document).ready(function () {
$("#current-eth-address").val(userAddress);
console.log("Currently connected user address", userAddress);
showUserResults(userAddress);
showLeaderBoard(userAddress);
}
else {
console.warn("dappHero.provider non-null but no user address given");
Expand Down

0 comments on commit 03f3c35

Please sign in to comment.