-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplayElements.js
35 lines (31 loc) · 1.07 KB
/
displayElements.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// HTML templates for display panels
const topScoresTemplate = function (topScores) {
console.log(
'Inside function topScoresTemplate, topscores is equal to:',
topScores
);
const contentTop = `
<h3>Top Scores</h3>
<ol>`;
let contentListItems = '';
for (let i = 0; i < topScores.length; i++) {
contentListItems += `
<li><span class="topscores-username">${topScores[i].username}</span>
<span class="topscores-score">${topScores[i].score}</span></li>`;
}
const contentBottom = `</ol>`;
return contentTop + contentListItems + contentBottom;
};
const userLoginTemplate = function (msg = '') {
const content = `
<h3>Enter your nickname to be listed in TOP 10 scores:</h3>
<form id="user-login" class="user-login-form">
<label for="username">max 10 characters</label>
<input id="username" type="text" placeholder="mycoolnick" maxlength="10" autofocus />
<button id="user-submit" type="submit">Submit</button>
</form>
<p id="status-msg">${msg}</p>
`;
return content;
};
export { topScoresTemplate, userLoginTemplate };