Skip to content

Commit

Permalink
Wetter; Temperatur hinzugefügt
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulaScharf committed Sep 11, 2024
1 parent 8669ac0 commit a630827
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
32 changes: 16 additions & 16 deletions clock.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
var clock = document.querySelector("#clock");
// var clock = document.querySelector("#clock");

// Inject the time in the UI
var renderTime = function () {
var time = new Date();
clock.textContent = time.toLocaleString("de-DE", {
year: "numeric",
month: "long",
day: "numeric",
hour: "numeric",
minute: "numeric",
second: "numeric",
hour12: false,
});
};
// // Inject the time in the UI
// var renderTime = function () {
// var time = new Date();
// clock.textContent = time.toLocaleString("de-DE", {
// year: "numeric",
// month: "long",
// day: "numeric",
// hour: "numeric",
// minute: "numeric",
// second: "numeric",
// hour12: false,
// });
// };

// Update the time every second
setInterval(renderTime, 1000);
// // Update the time every second
// setInterval(renderTime, 1000);
6 changes: 3 additions & 3 deletions dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
<main>
<div class="row">
<div class="col-12 col-md-4">
<!-- Element: Uhr -->
<div id="clock" class="alert alert-primary" role="alert"></div>

<div >Wetter</div>
<div id="Wetter" class="alert alert-primary" role="alert"></div>
<!-- Element: Idee des Tages -->
<div class="card rounded-3 shadow-sm">
<div class="card-header py-3">
Expand Down
10 changes: 7 additions & 3 deletions weather.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var clock = document.querySelector("clock");
var clock = document.querySelector("#Wetter");

var renderTime = async function () {
const apiURL = 'https://api.brightsky.dev/weather?lat=52&lon=7.6&date=2024-09-11';
Expand All @@ -7,12 +7,16 @@ var renderTime = async function () {
const data = await response.json();

if (data.weather && data.weather.length > 0){
clock.textContent = data.weather[0].temperature
var time = new Date();
time.getHours();
clock.textContent = data.weather[time.getHours()-1].temperature +"°"
}else {
clock.textContent = "No weather data available";
}
} catch (error){
console.error('Error fetching weather data:', error);
}

}
}
setInterval(renderTime, 1000);

0 comments on commit a630827

Please sign in to comment.