Skip to content

Commit 72ce8de

Browse files
authored
Update greeting.js
1 parent 37be841 commit 72ce8de

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

greeting.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,34 @@ function loadName() {
5959

6060
// Determine the appropriate greeting based on the time of day
6161
var ampm;
62+
var status;
6263

6364
// Determine the appropriate greeting based on the time of day
6465
var greeting;
6566
if (hour >= 0 && hour < 12) {
6667
greeting = "Good morning";
68+
status = '<i class="fa-solid fa-mug-saucer"></i>';
69+
status = '<i class="fa-solid fa-sun"></i> ';
6770
}
6871
else if (hour >= 12 && hour < 18) {
6972
greeting = "Good afternoon";
73+
status = '<i class="fa-solid fa-sun"></i> ';
7074
} else {
7175
greeting = "Good evening";
76+
status = '<i class="fa-solid fa-moon"></i> ';
77+
}
78+
79+
// Determine the appropriate day status based on the time of day
80+
if (hour >= 0 && hour < 6) {
81+
status = ' <i class="fa-regular fa-moon"></i>';
82+
}
83+
else if (hour >= 6 && hour < 12) {
84+
status = ' <i class="fa-regular fa-sun"></i>';
85+
}
86+
else if (hour >= 12 && hour < 18) {
87+
status = ' <i class="fa-regular fa-sun"></i>';
88+
} else {
89+
status = ' <i class="fa-regular fa-moon"></i>';
7290
}
7391

7492
if (hour >= 12) {
@@ -81,7 +99,7 @@ function loadName() {
8199

82100

83101
// Display the greeting with the current time in minutes
84-
document.getElementById("greeting").innerHTML = "<div class='greeting'><h1>" + hour + ":" + (minute < 10 ? "0" : "") + minute + " " + ampm + ", " + greeting + ", " + name + "!</h1></div>";
102+
document.getElementById("greeting").innerHTML = "<div class='greeting'><h1>" + hour + ":" + (minute < 10 ? "0" : "") + minute + " " + ampm + status + ", " + greeting + " " + name + "!</h1></div>";
85103
}, 1000); // Update every 1000 milliseconds (1 second)
86104

87105
// document.getElementById("greeting").innerHTML = greeting + ", " + name + "!";
@@ -133,7 +151,7 @@ if (timeSinceLastDisplayed > 1000) {
133151

134152
// Display the new message to the user
135153
const messageElement = document.getElementById("message");
136-
messageElement.innerText = randomMessage.text;
154+
messageElement.innerHTML = '<i class="fa-solid fa-quote-left fa-fade" style="color: #f9a03f;"></i> ' + randomMessage.text;
137155
// Show the motivation message div
138156
const motivationDiv = document.getElementById("motivation-message");
139157
motivationDiv.style.display = "block";
@@ -145,7 +163,7 @@ if (timeSinceLastDisplayed > 1000) {
145163
const lastDisplayedIndex = parseInt(lastDisplayed);
146164
const nextIndex = (lastDisplayedIndex + 1) % DEFAULT_MESSAGES.length;
147165
const messageElement = document.getElementById("message");
148-
messageElement.innerText = DEFAULT_MESSAGES[nextIndex];
166+
messageElement.innerHTML = '<i class="fa-solid fa-quote-left fa-fade" style="color: #f9a03f;"></i> ' + DEFAULT_MESSAGES[nextIndex];
149167
// Show the motivation message div
150168
const motivationDiv = document.getElementById("motivation-message");
151169
motivationDiv.style.display = "block";

0 commit comments

Comments
 (0)