diff --git a/pages/index.html b/pages/index.html index 2a2b8847..fb5944c7 100644 --- a/pages/index.html +++ b/pages/index.html @@ -39,7 +39,7 @@
-

Welcome Back

+

Welcome to NotesVault

Your Organized Learning Companion...

Keep your study notes and PYQs organized, easy to find, and always diff --git a/scripts/script.js b/scripts/script.js index 9502d411..6214d9ea 100644 --- a/scripts/script.js +++ b/scripts/script.js @@ -34,6 +34,28 @@ document.addEventListener('DOMContentLoaded', () => { return container.firstElementChild } + + const updateWelcomeUI = () => { + const user = localStorage.getItem('nv_user'); // truthy = logged in + const userName = (localStorage.getItem('nv_user_name') || '').trim(); + const welcomeText = document.querySelector('.welcome-text'); + const primaryCTA = document.querySelector('.cta-buttons .btn.btn-primary'); // Upload/Sign Up button + + // If elements aren't present on this page, do nothing + if (!welcomeText || !primaryCTA) return; + + if (user) { + // logged in + welcomeText.textContent = userName ? `Welcome back, ${userName}` : 'Welcome back'; + primaryCTA.setAttribute('href', 'upload.html'); + primaryCTA.innerHTML = 'Upload Notes'; + } else { + // logged out + welcomeText.textContent = 'Welcome to NotesVault'; + primaryCTA.setAttribute('href', 'signup.html'); + primaryCTA.innerHTML = 'Sign Up'; + } +}; // Search Function // const updateSemesters = () => { @@ -263,6 +285,9 @@ document.addEventListener('DOMContentLoaded', () => { // Load Back To Top Button DOM.backToTop = document.querySelector('.back-to-top') setupBackToTop() + // Update hero greeting & CTA based on auth + updateWelcomeUI(); + } init()