Format JS

This commit is contained in:
Tressley Cahill 2022-11-01 17:12:52 -04:00
parent 723d73e127
commit ec99ce4b15
2 changed files with 22 additions and 19 deletions

View File

@ -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,

View File

@ -1,24 +1,26 @@
function dateTime () {
const date = new Date();
let today = date.toDateString();
let time = date.toLocaleTimeString();
document.getElementById('date-time').innerHTML = '<p id="date">' + today + '</p><p id="time">' + time + '</p>';
setTimeout(dateTime, 1000);
function dateTime() {
const date = new Date();
let today = date.toDateString();
let time = date.toLocaleTimeString();
document.getElementById('date-time').innerHTML = '<p id="date">' + today + '</p><p id="time">' + time + '</p>';
setTimeout(dateTime, 1000);
}
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(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 + '&deg;C</p>';
});
var apiKey = 'fad9628260a1bc2ebaaf85a7dfe800d0';
fetch('https://api.openweathermap.org/data/2.5/weather?id=' + cityID + '&appid=' + apiKey)
.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" ' + 'title="' + tempF + '&deg;F">' + data.weather[0].description + '<span class="separator">|</span>' + tempC + '&deg;C</p>';
});
}
function traichu() {
dateTime();
weatherBalloon(6254926);
}
dateTime();
weatherBalloon(6254926);
}