diff --git a/public/assets/js/greetings.js b/public/assets/js/greetings.js
index 0b9a4366..83b3b10f 100644
--- a/public/assets/js/greetings.js
+++ b/public/assets/js/greetings.js
@@ -1,5 +1,6 @@
window.onload = function() {
const storedName = localStorage.getItem('userName');
+ const path = window.location.pathname;
if (!storedName) {
document.getElementById('overlay').style.display = 'block';
document.getElementById('namePrompt').style.display = 'block';
@@ -11,7 +12,9 @@ window.onload = function() {
});
return;
}
- showToast(`Hey, ${storedName}! Welcome back to Waves!`, 'success', 'wave');
+ const welcomeMsg = getWelcomeMessage(storedName);
+ const iconType = getIconType(path);
+ showToast(welcomeMsg, 'success', iconType);
const greetingElement = document.getElementById('greeting');
if (greetingElement) {
updateGreeting(storedName);
@@ -25,17 +28,41 @@ function submitName() {
updateGreeting(name);
document.getElementById('namePrompt').classList.add('fade-out');
showToast(`Hey, ${name}! Welcome to Waves!`, 'success', 'wave');
+ const path = window.location.pathname;
+
setTimeout(() => {
document.getElementById('namePrompt').style.display = 'none';
document.getElementById('overlay').style.display = 'none';
}, 300);
}
+function getWelcomeMessage(name) {
+ const path = window.location.pathname;
+ if (path === '/g') {
+ return `Have fun playing games, ${name}!`;
+ } else if (path === '/a') {
+ return `Enjoy our collection of apps, ${name}!`;
+ } else {
+ return `Welcome back, ${name}!`;
+ }
+}
+
+function getIconType(path) {
+ if (path === '/g') return 'game';
+ if (path === '/a') return 'apps';
+ return 'wave';
+}
+
function updateGreeting(name) {
const { text, icon } = getGreeting();
+
const el = document.getElementById('greeting');
if (el) {
- el.innerHTML = `${icon} ${text}, ${name}!`;
+ if (text === 'Hope you enjoy Waves') {
+ el.innerHTML = `${icon} ${text}, ${name} <3`;
+ } else {
+ el.innerHTML = `${icon} ${text}, ${name}!`;
+ }
el.style.opacity = 1;
}
}
@@ -43,17 +70,23 @@ function updateGreeting(name) {
function showToast(message, type = 'success', iconType = 'wave') {
const toast = document.createElement('div');
toast.className = `toast show ${type}`;
+
const icons = {
success: '',
- error: '',
- info: '',
+ error: '',
+ info: '',
warning: '',
- wave: ''
+ wave: '',
+ game: '',
+ apps: '',
};
- toast.innerHTML = `${icons[iconType] || icons.wave}${message} `;
+
+ toast.innerHTML = `${icons[iconType] || icons.wave}${message}`;
+
const progressBar = document.createElement('div');
progressBar.className = 'progress-bar';
toast.appendChild(progressBar);
+
const closeBtn = document.createElement('button');
closeBtn.className = 'toast-close';
closeBtn.innerHTML = '';
@@ -62,6 +95,7 @@ function showToast(message, type = 'success', iconType = 'wave') {
setTimeout(() => toast.remove(), 500);
});
toast.appendChild(closeBtn);
+
document.body.appendChild(toast);
setTimeout(() => {
toast.classList.add('hide');
@@ -72,32 +106,41 @@ function showToast(message, type = 'success', iconType = 'wave') {
function getGreeting() {
const now = new Date();
const hour = now.getHours();
- const day = now.getDay();
- const options = [];
+
+ const timeGreetings = [];
+ const generalGreetings = [
+ { text: 'Welcome aboard', icon: '' },
+ { text: 'Let’s do something great', icon: '' },
+ { text: 'Hope you enjoy Waves', icon: '' },
+ { text: 'Time to explore', icon: '' },
+ { text: 'Let’s roll', icon: '' },
+ { text: 'Another great visit', icon: '' },
+ { text: 'The adventure continues', icon: '' }
+ ];
if (hour >= 5 && hour < 12) {
- options.push(
+ timeGreetings.push(
{ text: 'Good morning, sunshine', icon: '' },
{ text: 'Here’s to a bright morning', icon: '' },
- { text: 'Morning vibes only', icon: '' },
+ { text: 'Enjoy your morning', icon: '' },
{ text: 'Your day starts here', icon: '' }
);
} else if (hour < 17) {
- options.push(
+ timeGreetings.push(
{ text: 'Good afternoon', icon: '' },
{ text: 'Hope your day is going well', icon: '' },
{ text: 'Keep up the pace', icon: '' },
{ text: 'Stay on track today', icon: '' }
);
} else if (hour < 21) {
- options.push(
+ timeGreetings.push(
{ text: 'Good evening', icon: '' },
{ text: 'Time to unwind', icon: '' },
{ text: 'Evening’s here—relax', icon: '' },
{ text: 'Breathe and recharge', icon: '' }
);
} else {
- options.push(
+ timeGreetings.push(
{ text: 'Good night', icon: '' },
{ text: 'Rest well', icon: '' },
{ text: 'Sweet dreams', icon: '' },
@@ -105,26 +148,8 @@ function getGreeting() {
);
}
- if (day === 4) {
- options.push(
- { text: 'Thursday mode: engaged', icon: '' },
- { text: 'Almost Friday', icon: '' },
- { text: 'Keep going', icon: '' }
- );
- }
+ const useGeneral = Math.random() < 0.5;
+ const pool = useGeneral ? generalGreetings : timeGreetings;
- if (day === 0 || day === 6) {
- options.push(
- { text: 'Happy weekend', icon: '' },
- { text: 'Enjoy some downtime', icon: '' }
- );
- } else {
- options.push(
- { text: 'You’ve got this', icon: '' },
- { text: 'One step at a time', icon: '' },
- { text: 'Summer is coming', icon: '' }
- );
- }
-
- return options[Math.floor(Math.random() * options.length)];
+ return pool[Math.floor(Math.random() * pool.length)];
}
\ No newline at end of file