-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
46 lines (32 loc) · 954 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
44
45
46
let defaultCityName;
const cityJSON=localStorage.getItem("defaultCityName");
if(cityJSON!==null) {
defaultCityName=JSON.parse(cityJSON);
}else{
defaultCityName="Skopje"
}
const getCityWeather= async (cityName) =>{
// if(cityName===""){
// cityName="Skopje";
// }
const city=new Weather(cityName);
const ui=new UI();
await city.getResults();
const cityObj=city.result;
ui.getCelsius();
ui.fillDOM(cityObj);
console.log(cityObj);
console.log(ui);
}
window.addEventListener("load", getCityWeather(defaultCityName));
const inputCity=document.querySelector("#city");
const changeBtn=document.querySelector("#w-changeBtn");
changeBtn.addEventListener("click", e=>{
defaultCityName=inputCity.value;
localStorage.setItem("defaultCityName", JSON.stringify(defaultCityName));
getCityWeather(defaultCityName);
})
// document.querySelector("#aaa").addEventListener("click", e=>{
// console.log("AAAAA");
// getCityWeather();
// })