-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
317 lines (281 loc) · 11.2 KB
/
Copy pathindex.html
File metadata and controls
317 lines (281 loc) · 11.2 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="icon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Digital Clock</title>
<style>
:root {
--clock-color: #00ffff;
/* Default clock color */
--bg-color: #f3f4f6;
/* Light background */
--text-color: #333333;
/* Dark text color */
--panel-bg-color: rgba(255, 255, 255, 0.9);
/* Light panel background */
--button-bg-color: #ffffff;
/* Light button background */
--button-bg-hover: #e0e0e0;
/* Light button hover background */
--button-border-color: #ddd;
/* Light button border color */
}
body {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background-color: var(--bg-color);
background-image: url(bg.png);
background-size: cover;
color: var(--text-color);
font-family: 'Arial', sans-serif;
margin: 0;
transition: background-color 0.3s ease, color 0.3s ease;
}
#clock-container {
text-align: center;
padding: 30px;
border-radius: 15px;
background-color: var(--panel-bg-color);
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
/* Lighter shadow for light mode */
animation: fadeIn 1s ease-in-out;
}
#clock {
font-size: 5rem;
font-weight: 700;
color: var(--clock-color);
margin: 0;
transition: color 0.3s ease-in-out;
display: inline-flex;
align-items: baseline;
gap: 10px;
text-shadow: 0 0 5px var(--clock-color);
}
#ampm {
font-size: 3.5rem;
font-weight: 600;
text-shadow: 0 0 5px #ddd;
}
#date {
font-size: 1.5rem;
margin-top: 10px;
color: var(--text-color);
text-shadow: 0 0 5px var(--text-color);
}
.settings {
position: absolute;
top: 20px;
display: flex;
gap: 10px;
}
select,
button {
padding: 8px 10px;
font-size: 1rem;
color: var(--text-color);
background-color: var(--button-bg-color);
border: 1px solid var(--button-border-color);
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s, color 0.3s;
}
select:hover,
button:hover {
background-color: var(--button-bg-hover);
}
#theme-indicator {
width: 20px;
height: 20px;
display: inline-block;
border-radius: 50%;
margin-left: 8px;
background-color: var(--clock-color);
vertical-align: middle;
transition: background-color 0.3s ease-in-out;
}
/* Dark Mode Variables */
body.dark-mode {
--bg-color: #0a0202;
/* Dark background */
--text-color: #ffffff;
/* White text color */
--panel-bg-color: rgba(0, 0, 0, 0.7);
/* Dark panel background */
--button-bg-color: #333333;
/* Dark button background */
--button-bg-hover: #444444;
/* Dark button hover background */
--button-border-color: #555555;
/* Dark button border color */
}
/* Responsive Design */
@media (max-width: 768px) {
#clock {
font-size: 4rem;
}
#date {
font-size: 1.2rem;
}
}
/* Animation */
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
</style>
</head>
<body>
<div id="clock-container">
<div id="clock">
<span id="time"></span><span id="ampm"></span>
</div>
<div id="date"></div>
</div>
<div class="settings" aria-label="Clock Settings">
<select id="theme-selector" aria-label="Theme Selector" onchange="changeTheme()">
<option value="#00ffff">Aqua</option>
<option value="#ff0000">Red</option>
<option value="#00ff00">Green</option>
<option value="#0000ff">Blue</option>
<option value="#ffff00">Yellow</option>
<option value="#FFC0CB">Pink</option>
<option value="#5dec10">Lime</option>
<option value="#7300ff">Purple</option>
<option value="#FFFFFF">White</option>
</select>
<select id="timezone-selector" aria-label="Timezone Selector" onchange="updateClock()">
<option value="local">Local Time</option>
<option value="UTC">UTC</option>
<option value="Asia/Kolkata">India (IST)</option>
<option value="America/New_York">New York (EST)</option>
<option value="Europe/London">London (GMT)</option>
<option value="Asia/Tokyo">Tokyo (JST)</option>
<option value="Australia/Sydney">Sydney (AEDT)</option>
</select>
<button id="format-toggle" onclick="toggleFormat()" aria-label="Toggle 12/24 Hour Format">12/24 Hour</button>
<button onclick="toggleDarkMode()" aria-label="Toggle Dark Mode">Dark Mode</button>
</div>
<script>
// Initialize with dark mode by default
let isDarkMode = true; // Default to dark mode
let is24HourFormat = localStorage.getItem('is24HourFormat') === 'true' || false;
let selectedTheme = localStorage.getItem('themeColor') || '#00ffff';
let selectedTimezone = localStorage.getItem('timezone') || 'local';
document.documentElement.style.setProperty('--clock-color', selectedTheme);
document.getElementById('theme-selector').value = selectedTheme;
document.getElementById('timezone-selector').value = selectedTimezone;
// Apply dark mode if set
if (isDarkMode) {
document.body.classList.add('dark-mode');
}
function updateClock() {
const now = new Date();
let hours = now.getHours();
let minutes = String(now.getMinutes()).padStart(2, '0');
let seconds = String(now.getSeconds()).padStart(2, '0');
let ampm = "";
if (selectedTimezone !== "local") {
const timeInZone = new Date(now.toLocaleString("en-US", { timeZone: selectedTimezone }));
hours = timeInZone.getHours();
minutes = String(timeInZone.getMinutes()).padStart(2, '0');
seconds = String(timeInZone.getSeconds()).padStart(2, '0');
}
if (!is24HourFormat) {
ampm = hours >= 12 ? "PM" : "AM";
hours = hours % 12 || 12;
}
// Set clock time
document.getElementById("time").textContent = `${String(hours).padStart(2, '0')}:${minutes}:${seconds}`;
document.getElementById("ampm").textContent = !is24HourFormat ? ampm : "";
// Set AM/PM colors based on clock color
let amColor, pmColor;
switch (selectedTheme) {
case '#00ffff': // Aqua
amColor = '#008b8b'; // Dark Cyan
pmColor = '#20b2aa'; // Light Sea Green
break;
case '#ff0000': // Red
amColor = '#8b0000'; // Dark Red
pmColor = '#f08080'; // Light Coral
break;
case '#00ff00': // Green
amColor = '#006400'; // Dark Green
pmColor = '#3cb371'; // Medium Sea Green
break;
case '#0000ff': // Blue
amColor = '#00008b'; // Dark Blue
pmColor = '#87cefa'; // Light Sky Blue
break;
case '#ffff00': // Yellow
amColor = 'gold'; // Goldenrod
pmColor = '#fafad2'; // Light Goldenrod Yellow
break;
case '#FFC0CB': // Pink
amColor = '#c71585'; // Medium Violet Red
pmColor = '#ffb6c1'; // Light Pink
break;
case '#5dec10': // Lime
amColor = '#556b2f'; // Dark Olive Green
pmColor = '#98fb98'; // Pale Green
break;
case '#7300ff': // Purple
amColor = '#9400d3'; // Dark Violet
pmColor = '#d8bfd8'; // Thistle
break;
case '#FFFFFF': // White
amColor = '#d3d3d3'; // Light Gray
pmColor = '#696969'; // Dim Gray
break;
default:
amColor = '#ffffff'; // Fallback for AM
pmColor = '#ffffff'; // Fallback for PM
break;
}
// Set the colors for AM/PM
document.getElementById("ampm").style.color = ampm === "AM" ? amColor : pmColor;
const options = { year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' };
document.getElementById("date").textContent = now.toLocaleDateString('en-US', options);
}
function changeTheme() {
selectedTheme = document.getElementById("theme-selector").value;
document.documentElement.style.setProperty('--clock-color', selectedTheme);
localStorage.setItem('themeColor', selectedTheme);
}
function toggleFormat() {
is24HourFormat = !is24HourFormat;
localStorage.setItem('is24HourFormat', is24HourFormat);
updateClock();
}
function toggleDarkMode() {
const body = document.body;
body.classList.toggle('dark-mode');
// Update clock color if needed
const darkMode = body.classList.contains('dark-mode');
if (darkMode) {
document.documentElement.style.setProperty('--bg-color', '#0a0202');
document.documentElement.style.setProperty('--text-color', '#ffffff');
document.documentElement.style.setProperty('--panel-bg-color', 'rgba(0, 0, 0, 0.7)');
} else {
document.documentElement.style.setProperty('--bg-color', '#f3f4f6');
document.documentElement.style.setProperty('--text-color', '#333333');
document.documentElement.style.setProperty('--panel-bg-color', 'rgba(255, 255, 255, 0.9)');
}
}
document.getElementById('timezone-selector').addEventListener('change', () => {
selectedTimezone = document.getElementById("timezone-selector").value;
localStorage.setItem('timezone', selectedTimezone);
updateClock();
});
setInterval(updateClock, 1000);
updateClock();
</script>
</body>
</html>