-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
72 lines (62 loc) · 2.49 KB
/
Copy pathscript.js
File metadata and controls
72 lines (62 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Function to update greeting, background, icon, and time
function updateGreeting() {
const now = new Date();
const hours = now.getHours();
const greetingElement = document.getElementById('greeting');
const iconElement = document.getElementById('icon');
const timeElement = document.getElementById('time');
let greeting, bgColor, iconName;
if (hours >= 5 && hours < 12) {
greeting = "Good Morning 🌅";
bgColor = "#A3D5FF";
iconName = "sunrise";
} else if (hours >= 12 && hours < 18) {
greeting = "Good Afternoon ☀️";
bgColor = "#FDBA74";
iconName = "sun";
} else {
greeting = "Good Evening 🌙";
bgColor = "#1E3A8A";
iconName = "moon";
}
greetingElement.textContent = greeting;
document.body.style.backgroundColor = bgColor;
// Update icon dynamically
iconElement.setAttribute("data-lucide", iconName);
lucide.createIcons();
// Display live time
const timeString = now.toLocaleTimeString();
timeElement.textContent = "Current Time: " + timeString;
}
// Function to personalize greeting and show random message
function setName() {
const name = document.getElementById('nameInput').value.trim();
const personalGreeting = document.getElementById('personalGreeting');
const randomMessageElement = document.getElementById('randomMessage');
const messages = [
"Keep shining, you’re doing great! ✨",
"Today is your day to sparkle! 🌟",
"Smile — it looks good on you! 😊",
"Every moment is a fresh beginning 🌈",
"You make the world brighter! 💫",
"Believe in yourself — you’ve got this 💪",
"Stay positive and keep moving forward 🌻",
"Your energy is contagious! 🔆",
"Good things are coming your way 🌼",
"You’re stronger than you think 💎"
];
if (name) {
personalGreeting.textContent = `Nice to see you, ${name}! 👋`;
personalGreeting.classList.add('fade-in');
// Select random message
const randomMessage = messages[Math.floor(Math.random() * messages.length)];
randomMessageElement.textContent = randomMessage;
randomMessageElement.classList.add('fade-in');
} else {
personalGreeting.textContent = "";
randomMessageElement.textContent = "";
}
}
// Initialize
setInterval(updateGreeting, 1000);
updateGreeting();