-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
573 lines (526 loc) · 17.3 KB
/
index.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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
<!DOCTYPE html>
<html lang="en">
<head>
<script data-ad-client="ca-pub-1887857964946050" async
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<title>Code Practice</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: 0px;
position: relative;
background-color: #f4f4f4;
}
a {
text-decoration: none;
color: inherit;
}
.table-cont {
width: 100%;
text-align: center;
padding: 5px 20px;
}
.table-cont-inner {
width: 100%;
text-align: center;
-webkit-appearance: none;
-webkit-box-shadow: 0px 8px 17px 0px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0px 8px 17px 0px rgba(0, 0, 0, 0.2);
box-shadow: 0px 8px 17px 0px rgba(0, 0, 0, 0.2);
}
.table {
font-style: normal;
font-weight: 300;
font-size: 1.4rem;
line-height: 2rem;
letter-spacing: 0.01rem;
color: #212121;
background-color: #f5f5f5;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-rendering: optimizeLegibility;
width: 100%;
max-width: 100%;
border-collapse: collapse;
}
.table tbody tr:nth-child(odd) {
background-color: #f2f2f2;
}
.table tbody tr:nth-child(even) {
background-color: #e6e6e6;
}
.table thead tr {
border-top: 1px solid grey;
border-bottom: 1px solid grey;
}
.table tr {
display: none;
border-left: 1px solid grey;
border-right: 1px solid grey;
}
.table tr.active {
display: table-row;
}
.table tbody tr.active {
-webkit-appearance: none;
-webkit-box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.2) inset;
-moz-box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.2) inset;
box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.2) inset;
}
.table tbody tr.active:hover {
background-color: rgba(130, 190, 254, 0.35) !important;
}
.table tbody tr.active.solved:hover {
background-color: rgb(150, 206, 150, 0.35) !important;
}
.table td {
text-align: left;
}
.table td:first-child {
width: 10px;
padding-left: 10px;
padding-right: 10px;
}
.table thead {
background-color: #cccccc;
}
.table tbody {
background-color: white;
border-bottom: 1px solid grey;
}
.table-link {
color: blue;
text-decoration: underline;
}
.pre-table-cont {
display: flex;
justify-content: space-between;
margin-left: 20px;
margin-right: 20px;
margin-top: 15px;
margin-bottom: 5px;
}
.table-solved-check-label,
.table-solved-check {
align-self: center;
}
.table-search {
min-width: 220px;
width: 30%;
padding: 7px;
border-radius: 4px;
border: 1px solid white;
outline: none;
-webkit-appearance: none;
-webkit-box-shadow: 0px 7px 16px 0px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0px 7px 16px 0px rgba(0, 0, 0, 0.2);
box-shadow: 0px 7px 16px 0px rgba(0, 0, 0, 0.2);
}
.table-search:focus {
border: 1px solid rgb(130, 190, 254);
}
.difficulty {
font-size: 75%;
color: white;
padding: 3px 5px;
border-radius: 4px;
}
.easy {
background-color: green;
}
.medium {
background-color: orange;
}
.hard {
background-color: red;
}
.completion {
margin-top: 70px;
width: 100%;
text-align: center;
margin-bottom: 10px;
}
.completion-score {
margin-top: 70px;
font-size: 20px;
width: 100%;
text-align: center;
margin-bottom: 10px;
}
.progress-cont {
width: 300px;
background: #e0e2e4;
height: 20px;
margin: 0 auto;
margin-bottom: 5px;
border-radius: 3px;
-webkit-appearance: none;
-webkit-box-shadow: 0px 3px 7px 0px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0px 3px 7px 0px rgba(0, 0, 0, 0.2);
box-shadow: 0px 3px 7px 0px rgba(0, 0, 0, 0.2);
}
.progress-inner {
width: 0%;
height: 20px;
background: skyblue;
border-radius: 3px;
transition: width 500ms;
-webkit-appearance: none;
-webkit-box-shadow: 0px 1px 7px 0px skyblue;
-moz-box-shadow: 0px 1px 7px 0px skyblue;
box-shadow: 0px 1px 7px 0px skyblue;
}
#completion-text {
height: 18px;
font-size: 16px;
text-align: center;
margin-bottom: 6px;
}
#show-more {
font-size: 20px;
width: 100%;
background-color: #cccccc;
padding-top: 6px;
padding-bottom: 6px;
text-align: center;
cursor: pointer;
border: 1px solid grey;
border-top: 0;
}
#show-more:hover {
background-color: rgb(180, 180, 180);
}
@media only screen and (max-width: 400px) and (orientation: portrait) {
.pre-table-cont {
margin-left: 5px;
margin-right: 5px;
}
.table-solved-check-label {
font-size: 12px;
}
.table-search {
font-size: 12px;
min-width: 200px;
}
.table-cont {
width: 100%;
text-align: center;
padding-left: 5px;
padding-right: 5px;
}
.completion-score {
font-size: 16px;
}
.progress-cont {
width: 200px;
height: 15px;
}
.progress-inner {
height: 15px;
}
#completion-text {
height: 14px;
font-size: 12px;
}
.table {
font-size: 1.2rem;
}
.difficulty {
font-size: 70%;
color: white;
padding: 3px 5px;
border-radius: 4px;
}
}
</style>
</head>
<body>
<nav>
<div id="nav" class="nav">
<ul>
<li>
<a href="javascript:void(0)" class="nav-a" draggable="false">Practice</a>
</li>
<li>
<a href="leaderboard.html" 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="completion">
<p class="completion-score">Score: <span id="score">0</span></p>
</div>
<div class="progress-cont">
<div id="progress-bar" class="progress-inner"></div>
</div>
<div id="completion-text">0.0% of problems solved</div>
<div class="pre-table-cont">
<input type="text" id="table-search" class="table-search" placeholder="Search by ID, Name, or Difficulty" />
<label for="table-solved-check" class="table-solved-check-label">Show Solved
<input type="checkbox" name="table-solved-check" id="table-solved-check" class="table-solved-check" checked />
</label>
</div>
<div class="table-cont">
<div class="table-cont-inner">
<table class="table">
<thead>
<tr>
<td></td>
<td>ID</td>
<td>Name</td>
<td>Difficulty</td>
</tr>
</thead>
<tbody>
<tr>
<td id="sum-solved"><svg width="10" height="10"></svg></td>
<td>1</td>
<td><a href="problems/sum" class="table-link">Sum</a></td>
<td><span class="difficulty easy">Easy</span></td>
</tr>
<tr>
<td id="product-solved"><svg width="10" height="10"></svg></td>
<td>2</td>
<td><a href="problems/product" class="table-link">Product</a></td>
<td><span class="difficulty easy">Easy</span></td>
</tr>
<tr>
<td id="min-solved"><svg width="10" height="10"></svg></td>
<td>3</td>
<td><a href="problems/min" class="table-link">Min</a></td>
<td><span class="difficulty easy">Easy</span></td>
</tr>
<tr>
<td id="max-solved"><svg width="10" height="10"></svg></td>
<td>4</td>
<td><a href="problems/max" class="table-link">Max</a></td>
<td><span class="difficulty easy">Easy</span></td>
</tr>
<tr>
<td id="ispalindrome-solved"><svg width="10" height="10"></svg></td>
<td>5</td>
<td><a href="problems/ispalindrome" class="table-link">IsPalindrome</a></td>
<td><span class="difficulty medium">Medium</span></td>
</tr>
<tr>
<td id="kthindexof-solved"><svg width="10" height="10"></svg></td>
<td>6</td>
<td><a href="problems/kthindexof" class="table-link">KthIndexOf</a></td>
<td><span class="difficulty easy">Easy</span></td>
</tr>
<tr>
<td id="mostfrequentint-solved"><svg width="10" height="10"></svg></td>
<td>7</td>
<td><a href="problems/mostfrequentint" class="table-link">MostFrequentInt</a></td>
<td><span class="difficulty medium">Medium</span></td>
</tr>
<tr>
<td id="islinear-solved"><svg width="10" height="10"></svg></td>
<td>8</td>
<td><a href="problems/islinear" class="table-link">IsLinear</a></td>
<td><span class="difficulty medium">Medium</span></td>
</tr>
<tr>
<td id="uppercasefirst-solved"><svg width="10" height="10"></svg></td>
<td>9</td>
<td><a href="problems/uppercasefirst" class="table-link">UpperCaseFirst</a></td>
<td><span class="difficulty easy">Easy</span></td>
</tr>
<tr>
<td id="eulerphi-solved"><svg width="10" height="10"></svg></td>
<td>10</td>
<td><a href="problems/eulerphi" class="table-link">EulerPhi</a></td>
<td><span class="difficulty hard">Hard</span></td>
</tr>
<tr>
<td id="distinctsort-solved"><svg width="10" height="10"></svg></td>
<td>11</td>
<td><a href="problems/distinctsort" class="table-link">DistinctSort</a></td>
<td><span class="difficulty medium">Medium</span></td>
</tr>
<tr>
<td id="isbetween-solved"><svg width="10" height="10"></svg></td>
<td>12</td>
<td><a href="problems/isbetween" class="table-link">IsBetween</a></td>
<td><span class="difficulty easy">Easy</span></td>
</tr>
</tbody>
</table>
<div id="show-more" hidden>Show More</div>
</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 src="js/jquery-3.5.1.min.js"></script>
<script src="js/nav.js"></script>
<script>
var problems = [
"sum",
"product",
"min",
"max",
"ispalindrome",
"kthindexof",
"mostfrequentint",
"islinear",
"uppercasefirst",
"eulerphi",
"distinctsort",
"isbetween",
];
var num_filtered = 10;
$(document).ready(function () {
$(".table tr").filter(":lt(11)").addClass("active");
for (var i = 0; i < problems.length; i++) {
$("#" + problems[i] + "-solve").show();
}
$("#show-more").show();
if (window.localStorage.getItem("score") != null && window.localStorage.getItem("percent_solved") != null) {
var pre_score = window.localStorage.getItem("score");
var pre_percent_solved = window.localStorage.getItem("percent_solved");
$("#score").text(pre_score);
$("#progress-bar").width(pre_percent_solved + "%");
$("#completion-text").text(pre_percent_solved + "% of problems solved");
} else {
$("#progress-bar").width("0%");
$("#completion-text").text("0.0% of problems solved");
}
});
</script>
<script src="https://www.gstatic.com/firebasejs/8.1.2/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.1.2/firebase-analytics.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.1.2/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.1.2/firebase-database.js"></script>
<script src="js/app.js"></script>
<script>
firebase.auth().onAuthStateChanged(function (user) {
if (user) {
var score_ref = firebase.database().ref("users/" + user.uid);
score_ref.once("value", (snapshot) => {
var score_val = snapshot.val()["num_solved"].count;
$("#score").text(score_val);
window.localStorage.setItem("score", score_val);
});
var problems_list = firebase.database().ref("users/" + user.uid + "/problems");
var problems_solved = 0;
problems_list.once("value", (snapshot) => {
const data = snapshot.val();
if (data != null) {
for (var i = 0; i < problems.length; i++) {
if (data[problems[i]] != undefined) {
$("#" + problems[i] + "-solved").html(
'<svg viewBox="0 0 512 512" width="10" title="check">' +
'<path fill="green" ' +
'd="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998' +
" 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203" +
' 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z" /></svg>'
);
$("#" + problems[i] + "-solved")
.parent()
.addClass("solved");
problems_solved++;
} else {
$("#" + problems[i] + "-solved").html('<svg width="10" height="10"></svg>');
}
}
var percent = (problems_solved / problems.length) * 100;
percent = percent.toFixed(1);
$("#progress-bar").width(percent + "%");
$("#completion-text").text(percent + "% of problems solved");
window.localStorage.setItem("percent_solved", percent);
}
});
} else {
for (var i = 0; i < problems.length; i++) {
$("#" + problems[i] + "-solved").html('<svg width="10" height="10"></svg>');
}
$("#score").text("0");
$("#progress-bar").width("0.0%");
$("#completion-text").text("0.0% of problems solved");
window.localStorage.setItem("score", 0);
var temp = 0.0;
temp = temp.toFixed(1);
window.localStorage.setItem("percent_solved", temp);
}
});
jQuery.expr[":"].icontains = function (a, i, m) {
return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0;
};
$("#table-solved-check").change(function () {
$(".table tbody tr").removeClass("active");
filterTable();
});
$("#show-more").click(function () {
num_filtered += 10;
filterTable();
});
$("#table-search").on("input", function () {
num_filtered = 10;
$(".table tbody tr").removeClass("active");
filterTable();
});
function filterTable() {
var filter = $("#table-solved-check").is(":checked") ? "" : ":not('.solved')";
$(".table tbody tr" + filter + ":icontains('" + $("#table-search").val() + "')")
.slice(0, num_filtered)
.addClass("active");
updateBackgroundColors();
if (num_filtered >= $(".table tr" + filter + ":icontains('" + $("#table-search").val() + "')").length) {
$("#show-more").hide();
} else {
$("#show-more").show();
}
}
function updateBackgroundColors() {
var filter = $("#table-solved-check").is(":checked") ? "" : ":not('.solved')";
$(".table tbody tr" + filter + ":icontains('" + $("#table-search").val() + "')")
.slice(0, num_filtered)
.each(function (i, e) {
if (i % 2 == 0) {
$(e).css("background-color", "#f2f2f2");
} else {
$(e).css("background-color", "#e6e6e6");
}
});
}
</script>
</body>
</html>