-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
168 lines (145 loc) · 6.06 KB
/
index.html
File metadata and controls
168 lines (145 loc) · 6.06 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Year Progress</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Abel&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Abel', sans-serif;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 20px;
margin: 0;
}
.css-selector {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
z-index: -1;
background: linear-gradient(var(--animation-angle), var(--season-colors));
background-size: 600% 600%;
-webkit-animation: AnimationName 16s ease infinite;
-moz-animation: AnimationName 16s ease infinite;
animation: AnimationName 16s ease infinite;
}
.progress-container {
text-align: center;
width: 100%;
}
.progress-container > div:first-child {
font-size: 3rem;
margin-bottom: 10px;
}
.progress {
height: 40px;
border-radius: 20px;
border: 2px solid black;
position: relative;
}
.progress-bar {
display: flex;
align-items: center;
justify-content: center;
border-radius: 20px;
font-weight: bold;
color: transparent; /* Hide the text color */
}
.progress-percentage {
position: absolute;
width: 100%;
text-align: center;
font-size: 2.5rem;
line-height: 40px;
color: black;
}
.countdown {
margin-top: 10px;
font-size: 2rem;
}
@keyframes AnimationName {
0%{background-position:67% 0%}
50%{background-position:34% 100%}
100%{background-position:67% 0%}
}
</style>
</head>
<body>
<div class="css-selector"></div>
<div class="progress-container">
<div>YEAR PROGRESS <span id="current-year"></span></div>
<div class="container">
<div class="row justify-content-center">
<div class="col-5">
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-percentage">0%</div>
</div>
</div>
</div>
</div>
<div class="countdown" id="countdown">Loading...</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script>
function setSeasonalBackgroundAndProgressBar() {
var now = new Date();
var month = now.getMonth() + 1;
var body = document.querySelector('.css-selector');
var springColors = '#F1E9C6, #662277, #8E37BF, #BF6E9E, #E7E881';
var summerColors = '#E0E4CC, #69D2E7, #A7DBD8, #F38630, #FA6900';
var autumnColors = '#F0CE4E, #BF2A23, #A6AD3C, #CF872E, #8A211D';
var winterColors = '#F9FAE5, #F2F4F2, #DDE2FC, #B9B5FC, #0E0E2F';
var angle = Math.floor(Math.random() * 360) + 'deg';
if (month >= 3 && month <= 5) {
body.style.setProperty('--season-colors', springColors);
} else if (month >= 6 && month <= 8) {
body.style.setProperty('--season-colors', summerColors);
} else if (month >= 9 && month <= 11) {
body.style.setProperty('--season-colors', autumnColors);
} else {
body.style.setProperty('--season-colors', winterColors);
}
body.style.setProperty('--animation-angle', angle);
// Kick off countdown and progress updates
updateCountdown();
}
function updateCountdown() {
var now = new Date();
var year = now.getFullYear();
var startOfYear = new Date(year, 0, 1);
var startNextYear = new Date(year + 1, 0, 1);
var timeLeft = startNextYear - now;
// Update progress bar
var progress = (now - startOfYear) / (startNextYear - startOfYear);
progress = Math.min(Math.max(progress, 0), 1);
var progressValue = (progress * 100).toFixed(0);
var progressBar = document.querySelector('.progress-bar');
var progressPercentage = document.querySelector('.progress-percentage');
progressBar.style.width = progressValue + '%';
progressBar.setAttribute('aria-valuenow', progressValue);
progressPercentage.textContent = progressValue + '%';
// Set current year
document.getElementById('current-year').textContent = year;
var days = Math.floor(timeLeft / (1000 * 60 * 60 * 24));
var hours = Math.floor((timeLeft % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((timeLeft % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((timeLeft % (1000 * 60)) / 1000);
document.getElementById('countdown').textContent = days + " days " + hours + " hours " + minutes + " minutes " + seconds + " seconds";
setTimeout(function() {
updateCountdown();
}, 1000);
}
setSeasonalBackgroundAndProgressBar();
</script>
</body>
</html>