File tree 4 files changed +147
-21
lines changed
4 files changed +147
-21
lines changed Original file line number Diff line number Diff line change
1
+ var preference = JSON . parse ( localStorage . getItem ( "dark" ) ) ;
2
+ if ( preference === null ) {
3
+ localStorage . setItem ( "dark" , false ) ;
4
+ preference = false ;
5
+ }
6
+ var checkBox = document . getElementById ( "checkDark" ) ;
7
+ if ( checkBox ) {
8
+ checkBox . checked = preference ;
9
+ }
10
+ const html = document . getElementsByTagName ( "html" ) [ 0 ] ;
11
+
12
+ if ( preference ) {
13
+ html . style . filter = "invert(0.9) hue-rotate(150deg)" ;
14
+ } else {
15
+ html . style . filter = "" ;
16
+ }
17
+
18
+ function toggle_darkmode ( ) {
19
+ preference = ! preference ;
20
+ checkBox . checked = preference ;
21
+ localStorage . setItem ( "dark" , preference ) ;
22
+
23
+ if ( preference ) {
24
+ html . style . filter = "invert(0.9) hue-rotate(150deg)" ;
25
+ } else {
26
+ html . style . filter = "" ;
27
+ }
28
+ }
Original file line number Diff line number Diff line change
1
+ html {
2
+ transition : color 300ms , background-color 300ms ;
3
+ }
4
+ .switch {
5
+ position : relative;
6
+ display : inline-block;
7
+ width : 60px ;
8
+ height : 34px ;
9
+ }
10
+
11
+ @media screen and (max-width : 600px ) {
12
+ .switch {
13
+ width : 80px ;
14
+ }
15
+ }
16
+
17
+ .switch input {
18
+ opacity : 0 ;
19
+ width : 0 ;
20
+ height : 0 ;
21
+ }
22
+
23
+ .slider {
24
+ position : absolute;
25
+ cursor : pointer;
26
+ top : 0 ;
27
+ left : 0 ;
28
+ right : 0 ;
29
+ bottom : 0 ;
30
+ background-color : # ccc ;
31
+ -webkit-transition : .4s ;
32
+ transition : .4s ;
33
+ }
34
+
35
+ .slider : before {
36
+ position : absolute;
37
+ content : "" ;
38
+ height : 26px ;
39
+ width : 26px ;
40
+ left : 4px ;
41
+ bottom : 4px ;
42
+ background-color : white;
43
+ -webkit-transition : .4s ;
44
+ transition : .4s ;
45
+ }
46
+
47
+ input : checked + .slider {
48
+ background-color : # 2196F3 ;
49
+ }
50
+
51
+ input : focus + .slider {
52
+ box-shadow : 0 0 1px # 2196F3 ;
53
+ }
54
+
55
+ input : checked + .slider : before {
56
+ -webkit-transform : translateX (26px );
57
+ -ms-transform : translateX (26px );
58
+ transform : translateX (26px );
59
+ }
60
+
61
+ /* Rounded sliders */
62
+ .slider .round {
63
+ border-radius : 34px ;
64
+ }
65
+
66
+ .slider .round : before {
67
+ border-radius : 50% ;
68
+ }
69
+
70
+ .toggle-container {
71
+ display : flex;
72
+ justify-content : center;
73
+ }
74
+
75
+ .toggle-container {
76
+ display : flex;
77
+ align-items : center;
78
+
79
+ em {
80
+ margin-left : 10px ;
81
+ font-size : 1rem ;
82
+ }
83
+ }
Original file line number Diff line number Diff line change 16
16
</img >
17
17
</a >
18
18
</div >
19
+ <div class =" toggle-container" >
20
+ <label class =" switch" >
21
+ <input type =" checkbox" onclick =" toggle_darkmode()" id =" checkDark" >
22
+ <span class =" slider round me-1" ></span >
23
+ </label >
24
+ <em > Dark Mode!</em >
25
+ </div >
19
26
<div >
20
27
<iframe class =" mt-1"
21
28
src =" https://ghbtns.com/github-btn.html?user=SysSn13&repo=leetcode-rating-predictor&type=star&count=true&size=large"
26
33
<div class =" row justify-content-center" >
27
34
<div class =" col-12" >
28
35
<style >
29
- th ,td {
30
- text-align : center !important ;
36
+ th ,
37
+ td {
38
+ text-align : center !important ;
31
39
}
32
40
</style >
33
41
<div class =" table-responsive-lg" >
43
51
</thead >
44
52
<tbody >
45
53
<% for ( let contest of contests ) { % >
46
- < tr>
47
- < td>
48
- < % if (contest .rankings_fetched ) { % >
49
- < a href= " /contest/<%= contest._id %>/ranking/1" style= " text-decoration:none" >< %= contest ._id % >< / a>
50
- < % } else {% >
51
- < %= contest ._id % >
52
- < % } % >
53
- < / td>
54
- < td class = " startTime" >< %= contest .startTime % >< / td>
55
- < td>< %= (contest .endTime - contest .startTime )/ 60000 % > minutes< / td>
56
- < td>
57
- < %= contest .rankings_fetched ? " Yes" : " No" % >
58
- < / td>
59
- < td>
60
- < %= contest .ratings_predicted ? " Yes" : " No" % >
61
- < / td>
62
- < / tr>
63
- < % } %>
54
+ < tr>
55
+ < td>
56
+ < % if (contest .rankings_fetched ) { % >
57
+ < a href= " /contest/<%= contest._id %>/ranking/1" style= " text-decoration:none" >
58
+ < %= contest ._id % >
59
+ < / a>
60
+ < % } else {% >
61
+ < %= contest ._id % >
62
+ < % } % >
63
+ < / td>
64
+ < td class = " startTime" >
65
+ < %= contest .startTime % >
66
+ < / td>
67
+ < td>
68
+ < %= (contest .endTime - contest .startTime )/ 60000 % > minutes
69
+ < / td>
70
+ < td>
71
+ < %= contest .rankings_fetched ? " Yes" : " No" % >
72
+ < / td>
73
+ < td>
74
+ < %= contest .ratings_predicted ? " Yes" : " No" % >
75
+ < / td>
76
+ < / tr>
77
+ < % } %>
64
78
</tbody >
65
79
</table >
66
80
</div >
Original file line number Diff line number Diff line change 12
12
<link href =" https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel =" stylesheet"
13
13
integrity =" sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin =" anonymous" >
14
14
<link rel =" stylesheet" href =" /stylesheets/main.css" >
15
+ <link rel =" stylesheet" href =" /stylesheets/darkmode.css" >
15
16
16
17
<link rel =" apple-touch-icon" sizes =" 180x180" href =" /apple-touch-icon.png" >
17
18
<link rel =" icon" type =" image/png" sizes =" 32x32" href =" /favicon-32x32.png" >
34
35
GitHub</a>
35
36
</div>
36
37
<%- body %>
37
- </div>
38
38
<footer class=" mt-4 " >
39
39
<p class=" text-center " >
40
40
Powered By: <a
48
48
integrity=" sha384-Atwg2Pkwv9vp0ygtn1JAojH0nYbwNJLPhwyoVbhoPwBhjQPR5VtM2+xf0Uwh9KtT " crossorigin=" anonymous " >
49
49
</script>
50
50
<%- script %>
51
+ <script src=" /js /darkmode.js " ></script>
51
52
</body>
52
53
53
54
</html>
You can’t perform that action at this time.
0 commit comments