-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
94 lines (87 loc) · 3.32 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="src\styles.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.33/moment-timezone-with-data-10-year-range.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
const myLocationSelect = document.querySelector("#cities");
const currentOption = myLocationSelect.querySelector("#city-local");
currentOption.value = moment.tz.guess();
// Event listener for "My location" select change
myLocationSelect.addEventListener("change", function () {
if (myLocationSelect.value === "current") {
myLocationSelect.value = moment.tz.guess();
}
});
});
</script>
<title>Time Zones Clocks by sarasjodin.com</title>
</head>
<body>
<div class="container">
<h1>Time Zones Clocks</h1>
<select id="cities">
<option name="city" value="">Select a city...</option>
<option id="city-local" value="current">My location
</option>
<option value="Europe/Stockholm">Stockholm 🇸🇪
</option>
<option value="America/New_York">New York 🇺🇸</option>
<option value="Pacific/Auckland">Auckland 🇦🇺</option>
</select>
<div class="city" id="city-1">
<div>
<h2>Los Angeles 🇺🇸</h2>
</h2>
<div class="date"></div>
</div>
<div class="time"></div>
</div>
<div class="city" id="city-2">
<div>
<h2>London 🇬🇧</h2>
</h2>
<div class="date"></div>
</div>
<div class="time"></div>
</div>
<div class="city" id="city-3">
<div>
<h2>Tokyo 🇯🇵</h2>
<div class="date"></div>
</div>
<div class="time"></div>
</div>
<div class="city" id="city-4">
<div>
<h2>Sydney 🇦🇺</h2>
<div class="date"></div>
</div>
<div class="time"></div>
</div>
</div>
<footer>
Coded by <a href="https://www.sarasjodin.com" target="_blank">
<strong>sarasjodin.com</strong></a>
and is
open
sourced on <a href="https://github.com/sarasjodin/TimeZoneClocks" target="_blank"><strong>GitHub</strong></a>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.33/moment-timezone-with-data-10-year-range.min.js"></script>
<script src="src/index.js">
// Reset dropdown box value to default on page reload
window.onload = function () {
let citiesSelectElement = document.querySelector("#cities");
citiesSelectElement.selectedIndex = 0;
};
</script>
</body>
</html>