Add weather information

This commit is contained in:
Tressley Cahill
2022-11-02 09:36:20 -04:00
parent ec99ce4b15
commit 970ddd9973
3 changed files with 59 additions and 19 deletions
+4 -3
View File
@@ -13,14 +13,15 @@ function weatherBalloon(cityID) {
return resp.json()
})
.then(function(data) {
let tempK = parseFloat(data.main.temp);
let weatherIcon = data.weather[0].icon;
let tempK = parseFloat(data.main.temp);
let tempC = Math.round(tempK - 273.15);
let tempF = Math.round((tempK - 273.15) * 1.8) + 32;
document.getElementById('weather').innerHTML = '<p id="location">' + data.name + '</p><p id="details" ' + 'title="' + tempF + '&deg;F">' + data.weather[0].description + '<span class="separator">|</span>' + tempC + '&deg;C</p>';
document.getElementById('weather').innerHTML = '<p id="location">' + data.name + '</p><p id="details" ' + 'title="' + tempF + '&deg;F">' + '<img src="http://openweathermap.org/img/wn/' + weatherIcon + '@2x.png">' + data.weather[0].description + '<span class="separator">|</span>' + tempC + '&deg;C</p>';
});
}
function traichu() {
dateTime();
weatherBalloon(6254926);
}
}