-
Notifications
You must be signed in to change notification settings - Fork 0
/
leaderboard.html
307 lines (268 loc) · 7.76 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<!DOCTYPE html>
<html lang="en">
<head>
<title>Leaderboard</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="css/nav.css" type="text/css" />
<style>
* {
box-sizing: border-box;
font-family: "Roboto", sans-serif;
scroll-behavior: smooth;
}
body {
margin: 0;
}
a {
color: inherit;
text-decoration: none;
}
.main-cont {
margin-top: 70px;
text-align: center;
}
.leaderboard {
width: 50%;
margin: 0 auto;
margin-bottom: 25px;
}
.leaderboard-title {
background-color: royalblue;
color: white;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
border-top: 1px solid black;
border-left: 1px solid black;
border-right: 1px solid black;
padding: 15px;
margin: 0;
}
.leaderboard-list {
list-style: none;
margin: 0;
padding: 0;
}
li.leaderboard-entry {
counter-increment: leaderboard;
font-weight: 500;
background-color: aliceblue;
position: relative;
padding-top: 15px;
padding-bottom: 15px;
border-top: 0;
border-bottom: 1px solid black;
border-left: 1px solid black;
border-right: 1px solid black;
cursor: pointer;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
li.leaderboard-entry:hover {
border-top: 1px solid black;
font-weight: 600;
z-index: 4;
transform: scale(1.1);
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25), 0 8px 8px rgba(0, 0, 0, 0.22);
background-color: #cce7ff;
}
ol:hover>li.leaderboard-entry:not(:hover) {
opacity: 0.6;
}
li.leaderboard-entry:before {
content: counter(leaderboard) "th";
font-size: 22px;
display: block;
text-align: center;
position: absolute;
left: 15px;
}
li.leaderboard-entry:first-child:before {
content: counter(leaderboard) "st";
}
li.leaderboard-entry:nth-child(2):before {
content: counter(leaderboard) "nd";
}
li.leaderboard-entry:nth-child(3):before {
content: counter(leaderboard) "rd";
}
li.leaderboard-entry:first-child {
border: 1px solid black;
}
.leaderboard-name {
font-size: 28px;
}
.leaderboard-score {
font-size: 30px;
position: absolute;
right: 15px;
}
.leaderboard-score-units {
font-size: 16px;
}
#leaderboard-loader span {
display: inline-block;
width: 20px;
height: 20px;
border-radius: 100%;
background-color: #3498db;
margin: 150px 5px;
}
#leaderboard-loader span:nth-child(1) {
animation: bounce 1s ease-in-out infinite;
}
#leaderboard-loader span:nth-child(2) {
animation: bounce 1s ease-in-out 0.33s infinite;
}
#leaderboard-loader span:nth-child(3) {
animation: bounce 1s ease-in-out 0.66s infinite;
}
@keyframes bounce {
0%,
75%,
100% {
-webkit-transform: translateY(0);
-ms-transform: translateY(0);
-o-transform: translateY(0);
transform: translateY(0);
}
25% {
-webkit-transform: translateY(-20px);
-ms-transform: translateY(-20px);
-o-transform: translateY(-20px);
transform: translateY(-20px);
}
}
@media only screen and (max-width: 900px) {
.leaderboard {
width: 70%;
}
li.leaderboard-entry:before {
font-size: 20px;
}
li.leaderboard-entry:hover {
transform: scale(1.08);
}
.leaderboard-name {
font-size: 24px;
}
.leaderboard-score {
font-size: 28px;
}
.leaderboard-score-units {
font-size: 14px;
}
}
@media only screen and (max-width: 600px) {
.leaderboard {
width: 90%;
}
li.leaderboard-entry:before {
font-size: 18px;
}
li.leaderboard-entry:hover {
transform: scale(1.05);
}
.leaderboard-name {
font-size: 23px;
}
.leaderboard-score {
font-size: 27px;
}
.leaderboard-score-units {
font-size: 13px;
}
}
</style>
</head>
<body>
<nav>
<div id="nav" class="nav">
<ul>
<li><a href="index.html" class="nav-a" draggable="false">Practice</a></li>
<li><a href="javascript:void(0)" class="nav-a" draggable="false">Leaderboard</a></li>
<li id="profile" style="display: none"><a href="/profile" class="nav-a" draggable="false">Profile</a></li>
<li id="login"><a href="#" onclick="return logInGoogle();" class="nav-a" draggable="false">Login</a></li>
<li id="logout" style="display: none">
<a href="#" onclick="return logOutGoogle();" class="nav-a" draggable="false">Logout</a>
</li>
<li class="navname">
<p class="name">Code Practice</p>
</li>
</ul>
</div>
<div class="navbar-cont">
<div class="navbar-hamburger-menu">
<span></span>
<span></span>
<span></span>
</div>
<div class="navbarname">
<p class="name">Code Practice</p>
</div>
</div>
</nav>
<div class="page-container">
<div class="content-wrapper">
<div class="main-cont">
<div id="leaderboard-loader"><span></span><span></span><span></span></div>
<div id="leaderboard" class="leaderboard" hidden>
<h2 class="leaderboard-title">Leaderboard</h2>
<ol id="leaderboard-list" class="leaderboard-list"></ol>
</div>
</div>
</div>
<footer>
<div class="container">
<span>Copyright © 2021 CodePractice
</span><a href="/about-us">About Us</a><a href="/privacy">Privacy
Policy</a><a href="/roadmap">Roadmap</a>
</div>
</footer>
</div>
<script type="text/javascript" src="js/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="js/nav.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.1.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.1.1/firebase-analytics.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.1.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.1.1/firebase-database.js"></script>
<script src="js/app.js"></script>
<script>
var leaderboard_data = [];
var leaderboard = firebase.database().ref("users").orderByChild("num_solved/count").limitToLast(5);
leaderboard.once("value", (snapshot) => {
snapshot.forEach((childSnapshot) => {
var childKey = childSnapshot.key;
var childData = childSnapshot.val();
leaderboard_data.push(childData);
});
for (var i = leaderboard_data.length - 1; i >= 0; i--) {
$("#leaderboard-list").append(
"<li class='leaderboard-entry' onclick='gotoProfile(\"" +
leaderboard_data[i].id.uid +
"\");'>" +
"<span class='leaderboard-name'>" +
leaderboard_data[i].name +
"</span><span class='leaderboard-score'>" +
leaderboard_data[i].num_solved.count +
"<span class='leaderboard-score-units'> points</span></span></li>"
);
}
$("#leaderboard-loader").fadeOut(300);
$("#leaderboard").delay(300).fadeIn(300);
});
function gotoProfile(uid) {
window.location = "/profile/index.html?uid=" + uid;
}
</script>
<script>
$("#leaderboard-list")
.mouseenter(function () {
$(".leaderboard-title").css("opacity", 0.6);
})
.mouseleave(function () {
$(".leaderboard-title").css("opacity", 1);
});
</script>
</body>
</html>