Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b327250

Browse files
author
Ruurd Bijlsma
committed
Added dates to high scores
1 parent 2d62819 commit b327250

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

highscore/main.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ body {
116116
font-size: 23px;
117117
}
118118

119+
.score-date {
120+
font-size: 10px;
121+
text-transform: uppercase;
122+
color: rgba(0, 0, 0, 0.5);
123+
}
124+
125+
.score[active] .score-date {
126+
font-size: 13px;
127+
text-transform: none;
128+
}
129+
119130
.user {
120131
font-weight: bold;
121132
transition: 0.1s;

highscore/script.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,17 @@ function showScore(e) {
8080
e.target.setAttribute('active', '');
8181
}
8282

83+
let months = ["January", "February", "March", "April", "May", "June", "July", "August", "October", "November", "December"];
84+
8385
function displayScores(element, scores) {
8486
let html = '';
85-
for (let score of scores) html += `
87+
for (let score of scores) {
88+
let date = new Date(score.date);
89+
html += `
8690
<li class="score" onclick="showScore(event)">
8791
<div class="user">${score.user}</div>
8892
<div class="total-score">${score.totalScore}</div>
93+
<div class="score-date">${date.getDay()} ${months[date.getMonth()]} ${date.getFullYear()}</div>
8994
<div class="hidden">
9095
<h4>Round scores</h4>
9196
<ol class="individual-scores">${score.individualScores.map(s => `<li>${s}</li>`).join('')}</ol>
@@ -100,5 +105,6 @@ function displayScores(element, scores) {
100105
</div>
101106
</li>
102107
`;
108+
}
103109
element.innerHTML = html;
104110
}

0 commit comments

Comments
 (0)