mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-04 13:01:10 +08:00
added leaderboard display on the result screen
This commit is contained in:
parent
28eab5000a
commit
359b6edec9
3 changed files with 45 additions and 1 deletions
|
@ -170,6 +170,8 @@ a:hover {
|
|||
|
||||
#leaderboards {
|
||||
width: 75vw;
|
||||
max-height: calc(100vh - 5rem);
|
||||
overflow-y: scroll;
|
||||
background: var(--bg-color);
|
||||
border-radius: var(--roundness);
|
||||
padding: 2rem;
|
||||
|
@ -885,7 +887,8 @@ key {
|
|||
"wpm key"
|
||||
"raw time"
|
||||
"source source"
|
||||
"testType infoAndTags";
|
||||
"testType infoAndTags"
|
||||
"leaderboards leaderboards";
|
||||
|
||||
.group {
|
||||
.top {
|
||||
|
@ -917,6 +920,22 @@ key {
|
|||
}
|
||||
}
|
||||
|
||||
.leaderboards {
|
||||
align-self: baseline;
|
||||
grid-area: leaderboards;
|
||||
color: var(--sub-color);
|
||||
|
||||
.top {
|
||||
font-size: 1rem;
|
||||
line-height: 1.25rem;
|
||||
}
|
||||
|
||||
.bottom {
|
||||
font-size: 1rem;
|
||||
line-height: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.source {
|
||||
align-self: baseline;
|
||||
grid-area: source;
|
||||
|
|
|
@ -299,6 +299,10 @@
|
|||
<div class="bottom">-</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="group leaderboards">
|
||||
<div class="top">leaderboards</div>
|
||||
<div class="bottom">-</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chart">
|
||||
<!-- <div class="title">wpm over time</div> -->
|
||||
|
|
|
@ -1072,6 +1072,7 @@ function showResult(difficultyFailed = false) {
|
|||
);
|
||||
wpmOverTimeChart.update({ duration: 0 });
|
||||
}
|
||||
$("#result .stats .leaderboards .bottom").html("checking...");
|
||||
testCompleted({
|
||||
uid: firebase.auth().currentUser.uid,
|
||||
obj: completedEvent,
|
||||
|
@ -1089,6 +1090,26 @@ function showResult(difficultyFailed = false) {
|
|||
} catch (e) {
|
||||
console.log("Analytics unavailable");
|
||||
}
|
||||
if (e.data.leaderboard === null) {
|
||||
$("#result .stats .leaderboards .bottom").html("not found");
|
||||
} else if (e.data.leaderboard === -1) {
|
||||
$("#result .stats .leaderboards .bottom").html(
|
||||
"not qualified"
|
||||
);
|
||||
} else if (e.data.leaderboard >= 0) {
|
||||
let pos = e.data.leaderboard + 1;
|
||||
let numend = "th";
|
||||
if (pos === 1) {
|
||||
numend = "st";
|
||||
} else if (pos === 2) {
|
||||
numend = "nd";
|
||||
} else if (pos === 3) {
|
||||
numend = "rd";
|
||||
}
|
||||
$("#result .stats .leaderboards .bottom").html(
|
||||
`${e.data.leaderboard}${numend} place`
|
||||
);
|
||||
}
|
||||
if (e.data.resultCode === 2) {
|
||||
//new pb
|
||||
if (!localPb) {
|
||||
|
|
Loading…
Reference in a new issue