Skip to content

Commit 0bc4014

Browse files
fixing lb
1 parent c5a2e3c commit 0bc4014

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

app.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,31 +313,38 @@ function renderLeaderboard() {
313313
tbody.innerHTML = "";
314314

315315
let placing = 1;
316-
let lastScore = null;
317316
let shown = 0;
318317
let userIsShown = false;
318+
let lastScore = null;
319+
let actualPlacing = 1;
319320

320321
for (let i = 0; i < leaderboardData.length; i++) {
321322
const user = leaderboardData[i];
322323
const isCurrentUser = user.uid === currentUserUid;
323324
const withinVisible = shown < currentVisibleCount;
324325

325326
if (withinVisible || (isCurrentUser && !userIsShown)) {
327+
// Only increment placing if score is lower
326328
if (lastScore !== null && user.score < lastScore) {
327-
placing = shown + 1; // so 1st = index 0 + 1, etc.
329+
placing = actualPlacing;
328330
}
329331

330332
const row = document.createElement("tr");
331333
row.innerHTML = `<td>${placing}</td><td>${user.name}</td><td>${user.score}</td>`;
332-
if (isCurrentUser) row.style.fontWeight = 'bold';
334+
if (isCurrentUser) {
335+
row.style.fontWeight = 'bold';
336+
row.classList.add("highlighted-user");
337+
userIsShown = true;
338+
}
333339

334340
tbody.appendChild(row);
335341

336342
if (!isCurrentUser) shown++;
337-
else { userIsShown = true; row.classList.add("highlighted-user"); }
338343

339344
lastScore = user.score;
340345
}
346+
347+
actualPlacing++;
341348
}
342349

343350
document.getElementById('show-more-btn').style.display =

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h2>Your Current Game</h2>
3030
<iframe id="userGame" src="" onload="hideIframeLoader(this)"></iframe>
3131
</div>
3232
<br>
33-
<button id="reportButton" style="display:none;" onclick="reportTroll()">Report Opponent</button>
33+
<button id="reportButton" style="display:none;" onclick="reportTroll()">Report Broken Game Link</button>
3434
</div>
3535

3636
<h2>Leaderboard</h2>

0 commit comments

Comments
 (0)