-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
43 lines (30 loc) · 967 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
34
35
36
37
38
39
40
41
42
43
//Init Storage
const storage = new Storage();
//Get Stored location data
const weatherLocation = storage.getLocationData();
//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);
//Change location event
document.getElementById('w-change-btn').addEventListener('click', (e) => {
const city = document.getElementById('city').value;
const country = document.getElementById('country').value;
// Change location
weather.changeLocation(city, country);
//Set Location in LS
storage.setLocationData(city, country);
//Get and Display weather
getWeather()
//Close model
$('#locModal').modal('hide');
});
function getWeather() {
weather.getWeather()
.then(result => {
ui.paint(result);
})
.catch(err => console.log(err));
}