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,
|
||||
|
||||
38
js/main.js
38
js/main.js
@ -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 + '°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 + '°F">' + data.weather[0].description + '<span class="separator">|</span>' + tempC + '°C</p>';
|
||||
});
|
||||
}
|
||||
|
||||
function traichu() {
|
||||
dateTime();
|
||||
weatherBalloon(6254926);
|
||||
}
|
||||
dateTime();
|
||||
weatherBalloon(6254926);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user