Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<section class="hero">
<div class="container">
<div class="hero-content">
<p class="welcome-text">Welcome Back</p>
<p class="welcome-text">Welcome to NotesVault</p>
<h1>Your Organized <span class="text-accent">Learning Companion...</span></h1>
<p class="subtext">
Keep your study notes and PYQs organized, easy to find, and always
Expand Down
25 changes: 25 additions & 0 deletions scripts/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<i class="fas fa-upload"></i>Upload Notes';
} else {
// logged out
welcomeText.textContent = 'Welcome to NotesVault';
primaryCTA.setAttribute('href', 'signup.html');
primaryCTA.innerHTML = '<i class="fas fa-user-plus"></i>Sign Up';
}
};

// Search Function //
const updateSemesters = () => {
Expand Down Expand Up @@ -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()
Expand Down
Loading