diff --git a/src/js/script.js b/src/js/script.js
index fcff3775a..3e7a670d6 100644
--- a/src/js/script.js
+++ b/src/js/script.js
@@ -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(`
+
${tag.name}
+ `);
+ 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 += "
" + 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")
diff --git a/src/sass/style.scss b/src/sass/style.scss
index 79215a8a2..dd71a89ec 100644
--- a/src/sass/style.scss
+++ b/src/sass/style.scss
@@ -1455,6 +1455,10 @@ key {
}
}
+ .tags .bottom .fas {
+ margin-left: 0.5rem;
+ }
+
.wpm {
grid-area: wpm;