Terminado el widget de clima
This commit is contained in:
@@ -24,14 +24,15 @@
|
|||||||
|
|
||||||
<div id="weather-box" class="box">
|
<div id="weather-box" class="box">
|
||||||
<div class="weather-description">
|
<div class="weather-description">
|
||||||
<span class="weather-degrees">11°</span>
|
<span class="weather-degrees">99º</span>
|
||||||
<span class="weather-where">Temuco</span>
|
<span class="weather-where">Nether</span>
|
||||||
</div>
|
</div>
|
||||||
<img class="weather-icon" src="http://openweathermap.org/img/wn/04n@4x.png"/>
|
<img class="weather-icon" src="http://openweathermap.org/img/wn/04n@4x.png"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="custom-box" class="box">
|
<div id="custom-box" class="box">
|
||||||
<p>Custom</p>
|
<pre>
|
||||||
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="currency-box" class="box">
|
<div id="currency-box" class="box">
|
||||||
|
|||||||
28
script.js
28
script.js
@@ -158,9 +158,9 @@ const photos = new function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.next_page = async () => {
|
this.next_page = async () => {
|
||||||
this.current_page++
|
this.current_page++
|
||||||
await this.clear_photos()
|
await this.clear_photos()
|
||||||
await this.fill_photos()
|
await this.fill_photos()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.previous_page = async () => {
|
this.previous_page = async () => {
|
||||||
@@ -205,11 +205,31 @@ const search = new function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const weather = new function () {
|
const weather = new function () {
|
||||||
|
this.query_weather = async (city) => {
|
||||||
|
const data = await fetch(`https://home.danielcortes.xyz/weather?city=${city}`)
|
||||||
|
return await data.json()
|
||||||
|
}
|
||||||
|
|
||||||
|
this.show_weather = async () => {
|
||||||
|
const degrees_span = document.getElementsByClassName('weather-degrees')[0]
|
||||||
|
const where_span = document.getElementsByClassName('weather-where')[0]
|
||||||
|
const icon_img = document.getElementsByClassName('weather-icon')[0]
|
||||||
|
|
||||||
|
const weather = await this.query_weather('temuco')
|
||||||
|
|
||||||
|
degrees_span.innerHTML = `${weather.temp}º`;
|
||||||
|
where_span.innerHTML = weather.name;
|
||||||
|
icon_img.src = weather.icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.on_load = () => {
|
||||||
|
this.show_weather()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
currency.on_load()
|
currency.on_load()
|
||||||
photos.on_load()
|
photos.on_load()
|
||||||
search.on_load()
|
search.on_load()
|
||||||
|
weather.on_load()
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user