-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
33 lines (25 loc) · 853 Bytes
/
app.js
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
// Init storage
const storage = new Storage();
// Get stored location data
const weatherLocation = storage.getLocationDate();
// Init weather object
const weather = new Weather(weatherLocation.city, weatherLocation.country);
// Init UI
const ui = new UI();
// Get weather on DOM load
document.addEventListener('DOMContentLoaded',getWeather)
function getWeather() {
weather.getWeather()
.then(results => ui.paint(results))
.catch(err => console.log(err));
}
// Change location event
document.getElementById('w-change-btn').addEventListener('click',(e) => {
const city = document.getElementById('city').value;
const country = document.getElementById('country').value;
weather.changeLocation(city, country);
// LS
storage.setLocationData(city,country);
getWeather();
modal.style.display = "none";
});