-
Notifications
You must be signed in to change notification settings - Fork 0
/
leaderboard.html
70 lines (44 loc) · 1.51 KB
/
leaderboard.html
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<link rel="manifest" href="manifest.json">
<link rel="icon" type="image/jpeg" href="./Burger.jpeg">
<title>LeaderBoard</title>
</head>
<body>
<h1> Leaderboard </h1>
<ol id="list">
</ol>
<script>
let currentUser = localStorage.getItem('name');
let currentUserScore = localStorage.getItem('score');
alert("Players with scores under than 100 do not qualify to be listed on the leaderboard");
//get scoreboard
const list = document.getElementById("list");
fetch("https://burger-world.beast-o.com/players").then((resp) => {
return resp.json();
}).then((data) => {
console.log(data)
data.map((elem) => {
let player = document.createElement("li");
player.setAttribute("id","playerScore");
if(elem.name == currentUser && elem.score == currentUserScore){
player.setAttribute("class", "my-score");
}
let name = document.createElement("span");
let score = document.createElement("span");
name.innerHTML = elem.name;
score.innerHTML = elem.score;
player.appendChild(name);
player.appendChild(score);
list.appendChild(player);
})
}).catch(error=>{
console.log(error)
})
</script>
</body>
</html>