abidlabs HF Staff commited on
Commit
d380d44
·
verified ·
1 Parent(s): 0547a6c

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +448 -18
index.html CHANGED
@@ -1,19 +1,449 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Your Time Zone - Share Times Across Timezones</title>
7
+ <style>
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ body {
15
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
16
+ background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
17
+ min-height: 100vh;
18
+ display: flex;
19
+ align-items: center;
20
+ justify-content: center;
21
+ padding: 20px;
22
+ }
23
+
24
+ .container {
25
+ background: white;
26
+ border-radius: 20px;
27
+ box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
28
+ padding: 40px;
29
+ max-width: 600px;
30
+ width: 100%;
31
+ text-align: center;
32
+ }
33
+
34
+ h1 {
35
+ color: #000;
36
+ margin-bottom: 30px;
37
+ font-size: 2.5rem;
38
+ font-weight: 700;
39
+ }
40
+
41
+ .time-input-section {
42
+ margin-bottom: 30px;
43
+ }
44
+
45
+ .input-group {
46
+ display: flex;
47
+ gap: 15px;
48
+ margin-bottom: 20px;
49
+ justify-content: center;
50
+ flex-wrap: wrap;
51
+ }
52
+
53
+ input[type="time"] {
54
+ padding: 15px;
55
+ border: 2px solid #e1e5e9;
56
+ border-radius: 10px;
57
+ font-size: 1.1rem;
58
+ outline: none;
59
+ transition: border-color 0.3s ease;
60
+ }
61
+
62
+ input[type="time"]:focus {
63
+ border-color: #f7931e;
64
+ }
65
+
66
+ select {
67
+ padding: 15px;
68
+ border: 2px solid #e1e5e9;
69
+ border-radius: 10px;
70
+ font-size: 1.1rem;
71
+ outline: none;
72
+ background: white;
73
+ cursor: pointer;
74
+ transition: border-color 0.3s ease;
75
+ }
76
+
77
+ select:focus {
78
+ border-color: #f7931e;
79
+ }
80
+
81
+ .generate-btn {
82
+ background: linear-gradient(135deg, #000 0%, #333 100%);
83
+ color: white;
84
+ border: none;
85
+ padding: 15px 30px;
86
+ border-radius: 10px;
87
+ font-size: 1.1rem;
88
+ font-weight: 600;
89
+ cursor: pointer;
90
+ transition: transform 0.2s ease;
91
+ margin-bottom: 20px;
92
+ }
93
+
94
+ .generate-btn:hover {
95
+ transform: translateY(-2px);
96
+ }
97
+
98
+ .shareable-url {
99
+ background: #f8f9fa;
100
+ border: 2px solid #e1e5e9;
101
+ border-radius: 10px;
102
+ padding: 20px;
103
+ margin-bottom: 20px;
104
+ word-break: break-all;
105
+ }
106
+
107
+ .shareable-url a {
108
+ color: #f7931e;
109
+ text-decoration: none;
110
+ font-weight: 600;
111
+ }
112
+
113
+ .shareable-url a:hover {
114
+ text-decoration: underline;
115
+ }
116
+
117
+ .copy-btn {
118
+ background: #ff6b35;
119
+ color: white;
120
+ border: none;
121
+ padding: 10px 20px;
122
+ border-radius: 8px;
123
+ font-size: 0.9rem;
124
+ cursor: pointer;
125
+ transition: background-color 0.3s ease;
126
+ }
127
+
128
+ .copy-btn:hover {
129
+ background: #e55a2b;
130
+ }
131
+
132
+ .conversion-result {
133
+ background: #f8f9fa;
134
+ border: 2px solid #e1e5e9;
135
+ border-radius: 10px;
136
+ padding: 30px;
137
+ margin-top: 20px;
138
+ display: none;
139
+ }
140
+
141
+ .conversion-result.show {
142
+ display: block;
143
+ }
144
+
145
+ .original-time {
146
+ font-size: 1.2rem;
147
+ color: #666;
148
+ margin-bottom: 15px;
149
+ }
150
+
151
+ .converted-time {
152
+ font-size: 2.5rem;
153
+ font-weight: 700;
154
+ color: #000;
155
+ margin-bottom: 10px;
156
+ }
157
+
158
+ .timezone-info {
159
+ font-size: 1rem;
160
+ color: #666;
161
+ }
162
+
163
+ .hidden {
164
+ display: none;
165
+ }
166
+
167
+ @media (max-width: 600px) {
168
+ .container {
169
+ padding: 20px;
170
+ }
171
+
172
+ h1 {
173
+ font-size: 2rem;
174
+ }
175
+
176
+ .input-group {
177
+ flex-direction: column;
178
+ align-items: center;
179
+ }
180
+
181
+ input[type="time"], select {
182
+ width: 100%;
183
+ max-width: 200px;
184
+ }
185
+ }
186
+ </style>
187
+ </head>
188
+ <body>
189
+ <div class="container">
190
+ <h1>Your Time Zone</h1>
191
+
192
+ <div class="time-input-section">
193
+ <div class="input-group">
194
+ <input type="time" id="timeInput" value="09:00" required>
195
+ <select id="timezoneSelect">
196
+ <option value="">Select your timezone</option>
197
+ </select>
198
+ </div>
199
+ <button class="generate-btn" onclick="generateShareableUrl()">Generate Shareable Link</button>
200
+ </div>
201
+
202
+ <div id="shareableUrlSection" class="hidden">
203
+ <h3>Share this link with others:</h3>
204
+ <div class="shareable-url">
205
+ <a id="shareableUrl" href="#" target="_blank"></a>
206
+ </div>
207
+ <button class="copy-btn" onclick="copyToClipboard()">Copy Link</button>
208
+ </div>
209
+
210
+ <div id="conversionResult" class="conversion-result">
211
+ <div class="original-time" id="originalTime"></div>
212
+ <div class="converted-time" id="convertedTime"></div>
213
+ <div class="timezone-info" id="timezoneInfo"></div>
214
+ </div>
215
+ </div>
216
+
217
+ <script>
218
+ const timezones = [
219
+ // Americas
220
+ { value: 'Pacific/Honolulu', label: 'Hawaii Time (HST) GMT-10' },
221
+ { value: 'America/Anchorage', label: 'Alaska Time (AKT) GMT-9' },
222
+ { value: 'America/Los_Angeles', label: 'Pacific Time (PT) GMT-8' },
223
+ { value: 'America/Phoenix', label: 'Arizona Time (MST) GMT-7' },
224
+ { value: 'America/Denver', label: 'Mountain Time (MT) GMT-7' },
225
+ { value: 'America/Chicago', label: 'Central Time (CT) GMT-6' },
226
+ { value: 'America/Mexico_City', label: 'Mexico City (CST) GMT-6' },
227
+ { value: 'America/New_York', label: 'Eastern Time (ET) GMT-5' },
228
+ { value: 'America/Toronto', label: 'Toronto (EST) GMT-5' },
229
+ { value: 'America/Caracas', label: 'Caracas (VET) GMT-4' },
230
+ { value: 'America/Santiago', label: 'Santiago (CLT) GMT-3' },
231
+ { value: 'America/Sao_Paulo', label: 'São Paulo (BRT) GMT-3' },
232
+ { value: 'America/Argentina/Buenos_Aires', label: 'Buenos Aires (ART) GMT-3' },
233
+ { value: 'Atlantic/Azores', label: 'Azores (AZOT) GMT-1' },
234
+
235
+ // Europe & Africa
236
+ { value: 'Europe/London', label: 'London (GMT) GMT+0' },
237
+ { value: 'Europe/Dublin', label: 'Dublin (IST) GMT+1' },
238
+ { value: 'Europe/Lisbon', label: 'Lisbon (WET) GMT+0' },
239
+ { value: 'Africa/Lagos', label: 'Lagos (WAT) GMT+1' },
240
+ { value: 'Europe/Paris', label: 'Paris (CET) GMT+1' },
241
+ { value: 'Europe/Berlin', label: 'Berlin (CET) GMT+1' },
242
+ { value: 'Europe/Rome', label: 'Rome (CET) GMT+1' },
243
+ { value: 'Europe/Madrid', label: 'Madrid (CET) GMT+1' },
244
+ { value: 'Europe/Amsterdam', label: 'Amsterdam (CET) GMT+1' },
245
+ { value: 'Europe/Brussels', label: 'Brussels (CET) GMT+1' },
246
+ { value: 'Europe/Vienna', label: 'Vienna (CET) GMT+1' },
247
+ { value: 'Europe/Warsaw', label: 'Warsaw (CET) GMT+1' },
248
+ { value: 'Africa/Cairo', label: 'Cairo (EET) GMT+2' },
249
+ { value: 'Africa/Johannesburg', label: 'Johannesburg (SAST) GMT+2' },
250
+ { value: 'Europe/Athens', label: 'Athens (EET) GMT+2' },
251
+ { value: 'Europe/Helsinki', label: 'Helsinki (EET) GMT+2' },
252
+ { value: 'Europe/Istanbul', label: 'Istanbul (TRT) GMT+3' },
253
+ { value: 'Europe/Moscow', label: 'Moscow (MSK) GMT+3' },
254
+ { value: 'Africa/Nairobi', label: 'Nairobi (EAT) GMT+3' },
255
+
256
+ // Middle East & Asia
257
+ { value: 'Asia/Dubai', label: 'Dubai (GST) GMT+4' },
258
+ { value: 'Asia/Karachi', label: 'Karachi (PKT) GMT+5' },
259
+ { value: 'Asia/Kolkata', label: 'India (IST) GMT+5:30' },
260
+ { value: 'Asia/Dhaka', label: 'Dhaka (BST) GMT+6' },
261
+ { value: 'Asia/Bangkok', label: 'Bangkok (ICT) GMT+7' },
262
+ { value: 'Asia/Jakarta', label: 'Jakarta (WIB) GMT+7' },
263
+ { value: 'Asia/Singapore', label: 'Singapore (SGT) GMT+8' },
264
+ { value: 'Asia/Hong_Kong', label: 'Hong Kong (HKT) GMT+8' },
265
+ { value: 'Asia/Shanghai', label: 'Beijing/Shanghai (CST) GMT+8' },
266
+ { value: 'Asia/Taipei', label: 'Taipei (CST) GMT+8' },
267
+ { value: 'Asia/Seoul', label: 'Seoul (KST) GMT+9' },
268
+ { value: 'Asia/Tokyo', label: 'Tokyo (JST) GMT+9' },
269
+
270
+ // Oceania
271
+ { value: 'Australia/Perth', label: 'Perth (AWST) GMT+8' },
272
+ { value: 'Australia/Adelaide', label: 'Adelaide (ACST) GMT+9:30' },
273
+ { value: 'Australia/Brisbane', label: 'Brisbane (AEST) GMT+10' },
274
+ { value: 'Australia/Sydney', label: 'Sydney (AEDT) GMT+11' },
275
+ { value: 'Australia/Melbourne', label: 'Melbourne (AEDT) GMT+11' },
276
+ { value: 'Pacific/Auckland', label: 'Auckland (NZDT) GMT+13' },
277
+ { value: 'Pacific/Fiji', label: 'Fiji (FJT) GMT+12' }
278
+ ];
279
+
280
+ function populateTimezones() {
281
+ const select = document.getElementById('timezoneSelect');
282
+ timezones.forEach(tz => {
283
+ const option = document.createElement('option');
284
+ option.value = tz.value;
285
+ option.textContent = tz.label;
286
+ select.appendChild(option);
287
+ });
288
+
289
+ const userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
290
+ const matchingOption = Array.from(select.options).find(option => option.value === userTimezone);
291
+ if (matchingOption) {
292
+ matchingOption.selected = true;
293
+ }
294
+ }
295
+
296
+ function generateShareableUrl() {
297
+ const time = document.getElementById('timeInput').value;
298
+ const timezone = document.getElementById('timezoneSelect').value;
299
+
300
+ if (!time || !timezone) {
301
+ alert('Please select both time and timezone');
302
+ return;
303
+ }
304
+
305
+ const url = new URL(window.location.href);
306
+ url.searchParams.set('time', time);
307
+ url.searchParams.set('tz', timezone);
308
+
309
+ document.getElementById('shareableUrl').href = url.toString();
310
+ document.getElementById('shareableUrl').textContent = url.toString();
311
+ document.getElementById('shareableUrlSection').classList.remove('hidden');
312
+ }
313
+
314
+ function copyToClipboard() {
315
+ const url = document.getElementById('shareableUrl').href;
316
+ navigator.clipboard.writeText(url).then(() => {
317
+ const btn = document.querySelector('.copy-btn');
318
+ const originalText = btn.textContent;
319
+ btn.textContent = 'Copied!';
320
+ setTimeout(() => {
321
+ btn.textContent = originalText;
322
+ }, 2000);
323
+ });
324
+ }
325
+
326
+ function convertTime() {
327
+ const urlParams = new URLSearchParams(window.location.search);
328
+ const time = urlParams.get('time');
329
+ const timezone = urlParams.get('tz');
330
+
331
+ if (time && timezone) {
332
+ const resultDiv = document.getElementById('conversionResult');
333
+ const originalTimeDiv = document.getElementById('originalTime');
334
+ const convertedTimeDiv = document.getElementById('convertedTime');
335
+ const timezoneInfoDiv = document.getElementById('timezoneInfo');
336
+
337
+ const [hours, minutes] = time.split(':');
338
+
339
+ // Get current date
340
+ const now = new Date();
341
+
342
+ // Create a date string for today in the format that works universally
343
+ const year = now.getFullYear();
344
+ const month = String(now.getMonth() + 1).padStart(2, '0');
345
+ const day = String(now.getDate()).padStart(2, '0');
346
+
347
+ // Build a date-time string
348
+ const dateTimeString = `${year}-${month}-${day} ${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:00`;
349
+
350
+ // Create dates for multiple possible interpretations and find the right one
351
+ // Try creating dates at different hours to find which one matches our target time in the source timezone
352
+ let correctDate = null;
353
+
354
+ // We'll iterate through possible UTC times to find the one that matches our target time in the source timezone
355
+ // Search around today's date
356
+ const baseTime = Date.UTC(year, now.getMonth(), now.getDate(), 12, 0, 0);
357
+
358
+ // First try hourly increments
359
+ for (let offsetHours = -24; offsetHours <= 24; offsetHours++) {
360
+ const testTime = baseTime + (offsetHours * 60 * 60 * 1000);
361
+ const testDate = new Date(testTime);
362
+
363
+ // Check what time this UTC time appears as in the source timezone
364
+ const testTimeInSourceTz = testDate.toLocaleTimeString('en-US', {
365
+ hour: '2-digit',
366
+ minute: '2-digit',
367
+ hour12: false,
368
+ timeZone: timezone
369
+ });
370
+
371
+ const targetTime = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`;
372
+
373
+ if (testTimeInSourceTz === targetTime) {
374
+ correctDate = testDate;
375
+ break;
376
+ }
377
+ }
378
+
379
+ // If we couldn't find an exact match with hourly search, try with finer granularity
380
+ if (!correctDate) {
381
+ for (let offsetMinutes = -1440; offsetMinutes <= 1440; offsetMinutes += 15) {
382
+ const testTime = baseTime + (offsetMinutes * 60 * 1000);
383
+ const testDate = new Date(testTime);
384
+
385
+ const testTimeInSourceTz = testDate.toLocaleTimeString('en-US', {
386
+ hour: '2-digit',
387
+ minute: '2-digit',
388
+ hour12: false,
389
+ timeZone: timezone
390
+ });
391
+
392
+ const targetTime = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`;
393
+
394
+ if (testTimeInSourceTz === targetTime) {
395
+ correctDate = testDate;
396
+ break;
397
+ }
398
+ }
399
+ }
400
+
401
+ // Display the original time exactly as entered
402
+ const originalHour = parseInt(hours);
403
+ const originalTimeString = `${originalHour % 12 || 12}:${String(minutes).padStart(2, '0')} ${originalHour >= 12 ? 'PM' : 'AM'}`;
404
+ const originalTimezoneAbbr = getTimezoneAbbr(timezone);
405
+ originalTimeDiv.textContent = `Original time: ${originalTimeString} ${originalTimezoneAbbr}`;
406
+
407
+ // Get user's timezone
408
+ const userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
409
+ const userTimezoneAbbr = getTimezoneAbbr(userTimezone);
410
+
411
+ // Convert to user's timezone if we found a valid date
412
+ if (correctDate) {
413
+ const convertedTimeString = correctDate.toLocaleTimeString('en-US', {
414
+ hour: 'numeric',
415
+ minute: '2-digit',
416
+ hour12: true,
417
+ timeZone: userTimezone
418
+ });
419
+
420
+ convertedTimeDiv.textContent = `${convertedTimeString} ${userTimezoneAbbr} for you!`;
421
+ } else {
422
+ // Fallback if conversion failed
423
+ convertedTimeDiv.textContent = `Unable to convert time accurately`;
424
+ }
425
+ timezoneInfoDiv.textContent = `Your timezone: ${userTimezone}`;
426
+
427
+ resultDiv.classList.add('show');
428
+
429
+ document.querySelector('.time-input-section').style.display = 'none';
430
+ document.getElementById('shareableUrlSection').style.display = 'none';
431
+ }
432
+ }
433
+
434
+ function getTimezoneAbbr(timezone) {
435
+ const date = new Date();
436
+ const abbr = date.toLocaleString('en-US', {
437
+ timeZone: timezone,
438
+ timeZoneName: 'short'
439
+ }).split(' ').pop();
440
+ return abbr;
441
+ }
442
+
443
+ window.onload = function() {
444
+ populateTimezones();
445
+ convertTime();
446
+ };
447
+ </script>
448
+ </body>
449
  </html>