Format JS
This commit is contained in:
parent
723d73e127
commit
ec99ce4b15
@ -27,7 +27,6 @@ header {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
|
||||
#date,
|
||||
#location {
|
||||
color: var(--primary-link-hover-color);
|
||||
@ -40,6 +39,8 @@ header {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
#weather { text-align: right; }
|
||||
|
||||
.separator { margin: 0 0.25rem; }
|
||||
|
||||
header img,
|
||||
|
||||
@ -9,12 +9,14 @@ function dateTime () {
|
||||
function weatherBalloon(cityID) {
|
||||
var apiKey = 'fad9628260a1bc2ebaaf85a7dfe800d0';
|
||||
fetch('https://api.openweathermap.org/data/2.5/weather?id=' + cityID + '&appid=' + apiKey)
|
||||
.then(function(resp) { return resp.json() })
|
||||
.then(function(resp) {
|
||||
return resp.json()
|
||||
})
|
||||
.then(function(data) {
|
||||
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">' + data.weather[0].description + '<span class="separator">|</span>' + tempC + '°C</p>';
|
||||
document.getElementById('weather').innerHTML = '<p id="location">' + data.name + '</p><p id="details" ' + 'title="' + tempF + '°F">' + data.weather[0].description + '<span class="separator">|</span>' + tempC + '°C</p>';
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user