-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (27 loc) · 897 Bytes
/
app.js
File metadata and controls
31 lines (27 loc) · 897 Bytes
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
const getTemp = new GetTemperatures();
const ui = new UI();
eventListeners();
function eventListeners() {
window.addEventListener("load", updateTempData);
}
function updateTempData() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(async (position) => {
const lat = position.coords.latitude;
const long = position.coords.longitude;
const result = await getTemp.getWeather(lat, long);
console.log(result);
console.log(result.name);
console.log(result.weather[0].icon);
console.log(result.weather[0].description);
ui.displayTemp(result.main.temp);
ui.displayPlace(result.name);
ui.displayDescription(result.weather[0].description);
ui.displayIcon(result.weather[0].icon);
});
} else {
alert(
"Hey you should provide location permission, so I can provide weather info!"
);
}
}