-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclock.html
More file actions
252 lines (224 loc) · 6.47 KB
/
clock.html
File metadata and controls
252 lines (224 loc) · 6.47 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Kerslake Clock</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
<link rel="icon" href="kerslake.png" type="image/x-icon">
<style>
:root {
--bg: #000;
--fg: #fff;
--progress-bg: #333;
--progress-bar: #fff;
}
body.light-mode {
--bg: #fff;
--fg: #111;
--progress-bg: #e5e5e5;
--progress-bar: #222;
}
body {
font-family: 'Roboto Condensed', sans-serif;
background-color: var(--bg);
margin: 0;
padding: 2rem;
color: var(--fg);
text-align: center;
transition: background 0.3s, color 0.3s;
}
h1 {
font-size: 3rem;
margin-bottom: 0.5rem;
}
.toggle-btn {
position: absolute;
top: 1.5rem;
right: 2rem;
background: var(--progress-bg);
color: var(--fg);
border: none;
border-radius: 2rem;
padding: 0.5rem 1.2rem;
font-size: 1.2rem;
cursor: pointer;
transition: background 0.3s, color 0.3s;
z-index: 10;
display: flex;
align-items: center;
gap: 0.5em;
}
.profile-container {
position: relative;
width: 150px;
height: 150px;
margin: 0 auto 1rem;
}
.profile-container img {
width: 100%;
height: 100%;
border-radius:50%;
border: 3px solid var(--fg);
object-fit: cover;
display: block;
z-index: 1;
}
.radar-trace {
position: absolute;
border-radius: 50%;
border: 3px solid transparent;
border-top: 3px solid transparent;
pointer-events: none;
z-index: 2;
}
.trace1 {
top: -4px;
left: -4px;
width: calc(100% + 8px);
height: calc(100% + 8px);
animation: spin 2s linear infinite;
}
.trace2 {
top: -10px;
left: -10px;
width: calc(100% + 20px);
height: calc(100% + 20px);
animation: spinReverse 5s linear infinite;
opacity: 0.6;
}
.trace3 {
top: -16px;
left: -16px;
width: calc(100% + 32px);
height: calc(100% + 32px);
animation: spin 7s linear infinite;
opacity: 0.4;
}
.trace4 {
top: -22px;
left: -22px;
width: calc(100% + 44px);
height: calc(100% + 44px);
animation: spinReverse 10s linear infinite;
opacity: 0.3;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@keyframes spinReverse {
0% { transform: rotate(360deg); }
100% { transform: rotate(0deg); }
}
.center-wrapper {
display: flex;
flex-direction: column;
margin-top: 100px;
align-items: center;
height: 80vh;
gap: 1rem;
}
.live-clock {
font-size: 10rem;
font-weight: 600;
color: var(--fg);
margin-top: 0.rem;
text-align: center;
}
.progress-container {
width: 100%;
max-width: 450px;
height: 10px;
background-color: var(--progress-bg);
border-radius: 10px;
margin: 2rem auto 0;
overflow: hidden;
position: relative;
}
.progress-bar {
width: 25%;
height: 100%;
background-color: var(--progress-bar);
border-radius: 10px;
position: absolute;
animation: bounce 2s infinite ease-in-out;
}
@keyframes bounce {
0% { left: 0%; }
50% { left: 75%; }
100% { left: 0%; }
}
</style>
</head>
<body>
<button class="toggle-btn" id="toggleMode" title="Toggle dark/light mode">
<i class="fa-solid fa-moon"></i>
</button>
<div class="center-wrapper">
<div class="profile-container">
<img id="profile-pic" src="images/circular_white.png" alt="Kerslake">
<div class="radar-trace trace1"></div>
<div class="radar-trace trace2"></div>
<div class="radar-trace trace3"></div>
<div class="radar-trace trace4"></div>
</div>
<div id="clock" class="live-clock"></div>
<div class="progress-container">
<div class="progress-bar"></div>
</div>
</div>
<script>
function updateClock() {
const clock = document.getElementById("clock");
const now = new Date();
const timeString = now.toLocaleTimeString();
clock.textContent = `${timeString}`;
}
setInterval(updateClock, 1000);
updateClock();
function getRandomColor() {
const hue = Math.floor(Math.random() * 360);
// Use darker traces in light mode, brighter in dark mode
const isLight = document.body.classList.contains('light-mode');
const lightness = isLight ? 35 : 50;
return `hsl(${hue}, 100%, ${lightness}%)`;
}
function setRadarTraceColors() {
document.querySelectorAll('.radar-trace').forEach(trace => {
trace.style.borderTopColor = getRandomColor();
});
}
// Initial color set
setRadarTraceColors();
// Get DOM elements for mode toggle
const toggleBtn = document.getElementById('toggleMode');
const body = document.body;
const icon = toggleBtn.querySelector('i');
const profilePic = document.getElementById('profile-pic');
function setMode(light) {
if (light) {
body.classList.add('light-mode');
icon.classList.remove('fa-moon');
icon.classList.add('fa-sun');
profilePic.src = 'images/circular_black.png'; // Use kerslake.png in light mode
} else {
body.classList.remove('light-mode');
icon.classList.remove('fa-sun');
icon.classList.add('fa-moon');
profilePic.src = 'images/circular_white.png';
}
setRadarTraceColors(); // Update radar trace colors on mode change
}
// Load mode from localStorage
const saved = localStorage.getItem('clock-mode');
setMode(saved === 'light');
toggleBtn.addEventListener('click', () => {
const isLight = !body.classList.contains('light-mode');
setMode(isLight);
localStorage.setItem('clock-mode', isLight ? 'light' : 'dark');
});
</script>
</body>
</html>