-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
34 lines (28 loc) · 817 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
// init storage
const storage = new Storage();
const weatherlocation = storage.getLocationData();
// init weather object
const weather = new Weather(weatherlocation.city);
// init UI
const ui = new UI;
// Get Weather on DoM loaded
document.addEventListener('DOMContentLoaded', getWeather);
// change location addeventlistener
document.getElementById('w-change-btn').addEventListener('click', (e) => {
const city = document.getElementById('city').value;
// get change weatherlocation
weather.changeLocation(city);
// set location in Localstorage
storage.setLocationData(city);
// get weather
getWeather();
// close modal
$('#locModal').modal('hide');
});
function getWeather() {
weather.getWeather()
.then(results => {
ui.plot(results);
})
.catch(err => console.log(err));
}