diff --git a/src/ui/Highscore.vue b/src/ui/Highscore.vue
index 89e1e8e..eb71897 100644
--- a/src/ui/Highscore.vue
+++ b/src/ui/Highscore.vue
@@ -7,7 +7,7 @@
-
- {{ person.name }} - {{ person.wins.length }}
+ {{ person.rank }}. {{ person.name }} - {{ person.wins.length }}
@@ -23,13 +23,26 @@ export default {
},
async mounted() {
let response = await highscoreStatistics();
- response.sort((a, b) => {
- return a.wins.length > b.wins.length ? -1 : 1;
- });
- response = response.filter(
- person => person.name != null && person.name != ""
- );
- this.highscore = response.slice(0, 10);
+ response.sort((a, b) => a.wins.length < b.wins.length ? 1 : -1)
+ this.highscore = this.generateScoreBoard(response.slice(0, 10));
+ },
+ methods: {
+ generateScoreBoard(highscore=this.highscore) {
+ let place = 0;
+ let highestWinCount = -1;
+
+ return highscore.map(win => {
+ const wins = win.wins.length
+ if (wins != highestWinCount) {
+ place += 1
+ highestWinCount = wins
+ }
+
+ const placeString = place.toString().padStart(2, "0");
+ win.rank = placeString;
+ return win
+ })
+ }
}
};
@@ -67,19 +80,8 @@ ol {
counter-reset: item;
& > li {
padding: 2.5px 0;
- width: max-content;
margin: 0 0 0 -1.25rem;
- padding: 0;
list-style-type: none;
- counter-increment: item;
- &:before {
- display: inline-block;
- width: 1em;
- padding-right: 0.5rem;
- font-weight: bold;
- text-align: right;
- content: counter(item) ".";
- }
@include mobile {
padding: 5px 0;