mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-05 21:33:40 +08:00
showing tag pbs
This commit is contained in:
parent
ea76ba5ac9
commit
adbccb498f
2 changed files with 34 additions and 19 deletions
|
@ -2003,10 +2003,12 @@ function showResult(difficultyFailed = false) {
|
|||
Misc.showNotification("Test invalid - repeated", 2000);
|
||||
} else {
|
||||
let activeTags = [];
|
||||
let activeTagsIds = [];
|
||||
try {
|
||||
db_getSnapshot().tags.forEach((tag) => {
|
||||
if (tag.active === true) {
|
||||
activeTags.push(tag.id);
|
||||
activeTags.push(tag);
|
||||
activeTagsIds.push(tag.id);
|
||||
}
|
||||
});
|
||||
} catch (e) {}
|
||||
|
@ -2049,7 +2051,7 @@ function showResult(difficultyFailed = false) {
|
|||
afkDuration: afkseconds,
|
||||
blindMode: config.blindMode,
|
||||
theme: config.theme,
|
||||
tags: activeTags,
|
||||
tags: activeTagsIds,
|
||||
keySpacing: keypressStats.spacing.array,
|
||||
keyDuration: keypressStats.duration.array,
|
||||
consistency: consistency,
|
||||
|
@ -2129,6 +2131,32 @@ function showResult(difficultyFailed = false) {
|
|||
}
|
||||
$("#result .stats .leaderboards").removeClass("hidden");
|
||||
$("#result .stats .leaderboards .bottom").html("checking...");
|
||||
|
||||
if (activeTags.length == 0) {
|
||||
$("#result .stats .tags").addClass("hidden");
|
||||
} else {
|
||||
$("#result .stats .tags").removeClass("hidden");
|
||||
}
|
||||
$("#result .stats .tags .bottom").text("");
|
||||
activeTags.forEach(async (tag) => {
|
||||
let tpb = await db_getLocalTagPB(tag.id);
|
||||
$("#result .stats .tags .bottom").append(`
|
||||
<div tagid="${tag.id}" aria-label="PB: ${tpb}" data-balloon-pos="up">${tag.name}<i class="fas fa-crown hidden"></i></div>
|
||||
`);
|
||||
if (tpb < stats.wpm) {
|
||||
//new pb for that tag
|
||||
db_saveLocalTagPB(tag.id, stats.wpm);
|
||||
$(
|
||||
`#result .stats .tags .bottom div[tagid="${tag.id}"] .fas`
|
||||
).removeClass("hidden");
|
||||
$(`#result .stats .tags .bottom div[tagid="${tag.id}"]`).attr(
|
||||
"aria-label",
|
||||
"+" + Misc.roundTo2(stats.wpm - tpb)
|
||||
);
|
||||
console.log("new pb for tag " + tag.name);
|
||||
}
|
||||
});
|
||||
|
||||
CloudFunctions.testCompleted({
|
||||
uid: firebase.auth().currentUser.uid,
|
||||
obj: completedEvent,
|
||||
|
@ -2506,23 +2534,6 @@ function showResult(difficultyFailed = false) {
|
|||
$("#result .stats .info .bottom").html(otherText);
|
||||
}
|
||||
|
||||
let tagsText = "";
|
||||
try {
|
||||
db_getSnapshot().tags.forEach((tag) => {
|
||||
if (tag.active === true) {
|
||||
tagsText += "<br>" + tag.name;
|
||||
}
|
||||
});
|
||||
} catch (e) {}
|
||||
|
||||
if (tagsText == "") {
|
||||
$("#result .stats .tags").addClass("hidden");
|
||||
} else {
|
||||
$("#result .stats .tags").removeClass("hidden");
|
||||
tagsText = tagsText.substring(4);
|
||||
$("#result .stats .tags .bottom").html(tagsText);
|
||||
}
|
||||
|
||||
if (
|
||||
$("#result .stats .tags").hasClass("hidden") &&
|
||||
$("#result .stats .info").hasClass("hidden")
|
||||
|
|
|
@ -1455,6 +1455,10 @@ key {
|
|||
}
|
||||
}
|
||||
|
||||
.tags .bottom .fas {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
.wpm {
|
||||
grid-area: wpm;
|
||||
|
||||
|
|
Loading…
Reference in a new issue