-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
164 lines (158 loc) · 7.43 KB
/
index.html
File metadata and controls
164 lines (158 loc) · 7.43 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="apple-touch-icon" href="assets/img/app-icon.png" />
<link rel="apple-touch-icon" sizes="152x152" href="assets/icon0.png" />
<link rel="apple-touch-icon" sizes="167x167" href="assets/icon1.png" />
<link rel="apple-touch-icon" sizes="180x180" href="assets/icon2.png" />
<link rel="apple-touch-icon" sizes="192x192" href="assets/icon3.png" />
<link rel="manifest" href="manifest.json"/>
<meta name="theme-color" content="#0066cc" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="WeatherApp" />
<title>Weather App</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css">
</head>
<body class="bg-dark">
<div class="col-12 d-flex justify-content-center align-items-center min-vh-100">
<div class="container" role="main">
<div class="row g-0">
<div class="col-sm">
<div class="card col-12 border-0 rounded-0 h-100" id="divLocation">
<div class="card-body text-center d-flex flex-column justify-content-center align-items-center">
<i class="bi bi-geo-alt" style="font-size: 3rem; color: rgb(221, 35, 35);"></i>
<h2 style="color: rgb(221, 35, 35);">Chicago</h2>
<footer>
<p><a href="https://open-meteo.com/">Weather data by Open-Meteo.com</a></p>
</footer>
</div>
</div>
</div>
<div class="col-sm d-sm-none">
<div class="card col-12 border-0 rounded-0 h-100" id="divConditions">
<hr class="w-75 mx-auto mt-0">
</div>
</div>
<div class="col-sm">
<div class="card col-12 border-0 rounded-0 h-100" id="divConditions">
<div class="card-body text-center">
<h2>Current Conditions</h2>
<i id="iconWeather" class="bi bi-geo-alt" style="font-size: 3rem;"></i>
</div>
<hr class="w-75 mx-auto">
<div class="card-body text-center">
<div class="d-flex mx-5 justify-content-center align-items-center">
<div class="mx-5 d-flex justify-content-center align-items-center">
<i class="bi bi-thermometer-half" style="font-size: 3rem; color:orange"></i>
<div id="divTemperature" style="font-size: 2rem;">??°</div>
</div>
<div class="mx-5 d-flex justify-content-center align-items-center">
<i class="bi bi-droplet-half" style="font-size: 3rem; color: blue;"></i>
<div id="divHumidity" style="font-size: 2rem;">??%</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
<script>
// Get the data from the weather api and fill the text content of the divs with the appropriate data
fetch("https://api.open-meteo.com/v1/forecast?latitude=41.85&longitude=-87.65¤t=temperature_2m,relative_humidity_2m,weather_code,cloud_cover&timezone=auto&temperature_unit=fahrenheit")
.then(response => {
if(response.ok) {
return response.json()
} else {
throw new Error(response.status)
}
}).then(data => {
document.querySelector('#divTemperature').textContent = data.current.temperature_2m + "°"
document.querySelector('#divHumidity').textContent = data.current.relative_humidity_2m + "%"
/*
case clearSky = 0
case mainlyClear = 1
case partlyCloudy = 2
case overcast = 3
case fog = 45
case depositingRimeFog = 48
case lightDrizzle = 51
case moderateDrizzle = 53
case denseDrizzle = 55
case lightFreezingDrizzle = 56
case moderateOrDenseFreezingDrizzle = 57
case lightRain = 61
case moderateRain = 63
case heavyRain = 65
case lightFreezingRain = 66
case moderateOrHeavyFreezingRain = 67
case slightSnowfall = 71
case moderateSnowfall = 73
case heavySnowfall = 75
case snowGrains = 77
case slightRainShowers = 80
case moderateRainShowers = 81
case heavyRainShowers = 82
case slightSnowShowers = 85
case heavySnowShowers = 86
case thunderstormSlightOrModerate = 95
case thunderstormStrong = 96
case thunderstormHeavy = 99
*/
switch (data.current.weather_code) {
case 0:
document.querySelector('#iconWeather').setAttribute('class',"bi bi-sun")
break;
case 1,2:
document.querySelector('#iconWeather').setAttribute('class',"bi bi-cloud-sun")
break;
case 3:
document.querySelector('#iconWeather').setAttribute('class',"bi bi-cloudy")
break;
case 45:
case 48:
document.querySelector('#iconWeather').setAttribute('class',"bi bi-cloud-fog")
break;
case 51:
case 53:
case 55:
case 56:
case 57:
document.querySelector('#iconWeather').setAttribute('class',"bi bi-cloud-drizzle")
break;
case 61:
case 63:
case 80:
case 81:
document.querySelector('#iconWeather').setAttribute('class',"bi bi-cloud-rain")
break;
case 65:
case 67:
case 81:
case 82:
document.querySelector('#iconWeather').setAttribute('class',"bi bi-cloud-rain-heavy")
break;
case 71:
case 73:
case 75:
case 77:
case 85:
case 86:
document.querySelector('#iconWeather').setAttribute('class',"bi bi-cloud-snow")
break;
case 95:
case 96:
case 99:
document.querySelector('#iconWeather').setAttribute('class',"bi bi-cloud-lightning-rain")
break;
default:
break;
}
})
</script>
</body>
</html>