-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.js
More file actions
32 lines (31 loc) · 1.31 KB
/
ui.js
File metadata and controls
32 lines (31 loc) · 1.31 KB
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
class UI {
constructor() {
this.location = document.getElementById("w-location");
this.desc = document.getElementById("w-desc");
this.string = document.getElementById("w-string");
this.details = document.getElementById("w-details");
this.icon = document.getElementById("w-icon");
this.humidity = document.getElementById("w-humidity");
this.feelsLike = document.getElementById("w-feels-like");
this.dewpoint = document.getElementById("w-dewpoint");
this.wind = document.getElementById("w-wind");
}
paint(weather) {
console.log(weather);
this.location.textContent = weather.name + " " + weather.sys.country;
this.desc.textContent = weather.weather[0].description;
this.string.textContent = (weather.main.temp - 273).toFixed(2) + " C";
console.log(weather.main.temp);
this.icon.setAttribute(
"src",
`https://openweathermap.org/img/wn/${weather.weather[0].icon}@2x.png`
);
console.log(
`https://openweathermap.org/img/wn/${weather.weather[0].icon}@2x.png`
);
this.humidity.textContent = `Relative Humidity: ${weather.main.humidity}`;
this.feelsLike.textContent = `Feels Like: ${weather.main.feels_like}`;
// this.dewpoint.textContent = `Dew Point: ${weather.main.humidity}`;
this.wind.textContent = `Wind: ${weather.wind.speed}`;
}
}