Skip to content
Open
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
57 changes: 35 additions & 22 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -534,40 +534,51 @@ <h3 style="font-size:12px; font-weight:700; text-transform:uppercase; color:var(
if (!profileBtn) return;
if (!userStr) {
profileBtn.innerHTML = 'Profile';
profilePopover.style.display = 'none';
if (profilePopover) {
profilePopover.style.display = 'none';
}
return;
}

let user;
try { user = JSON.parse(userStr); } catch (e) { user = { email: userStr }; }
const name = user.name || (user.email ? user.email.split('@')[0] : 'User');
const avatar = `https://ui-avatars.com/api/?name=${encodeURIComponent(name)}&background=4f46e5&color=fff&size=128`;
profileBtn.innerHTML = `<img src="${avatar}" alt="avatar" style="width:28px;height:28px;border-radius:50%;vertical-align:middle;margin-right:8px;"> ${name}`;
profilePopover.innerHTML = `
<div style="display:flex; gap:12px; align-items:center;">
<img src="${avatar}" style="width:64px;height:64px;border-radius:50%">
<div>
<div style="font-weight:700">${name}</div>
<div style="color:#666; font-size:13px;">${user.email || ''}</div>

if (profilePopover) {
profilePopover.innerHTML = `
<div style="display:flex; gap:12px; align-items:center;">
<img src="${avatar}" style="width:64px;height:64px;border-radius:50%">
<div>
<div style="font-weight:700">${name}</div>
<div style="color:#666; font-size:13px;">${user.email || ''}</div>
</div>
</div>
</div>
<div style="margin-top:12px;">
<button id="popover-logout" style="width:100%; padding:8px; border-radius:8px; border:1px solid #ddd; background:#fff; cursor:pointer;">Logout</button>
</div>
`;
<div style="margin-top:12px;">
<button id="popover-logout" style="width:100%; padding:8px; border-radius:8px; border:1px solid #ddd; background:#fff; cursor:pointer;">Logout</button>
</div>
`;
}
}

profileBtn.addEventListener('click', (e) => {
if (!localStorage.getItem('studyplan_user')) {
document.getElementById('auth-modal').style.display = 'flex';
return;
}
profilePopover.style.display = profilePopover.style.display === 'block' ? 'none' : 'block';
const expanded = profilePopover.style.display === 'block';
profileBtn.setAttribute('aria-expanded', expanded ? 'true' : 'false');
});
if (profileBtn) {
profileBtn.addEventListener('click', (e) => {
if (!localStorage.getItem('studyplan_user')) {
document.getElementById('auth-modal').style.display = 'flex';
return;
}
if (profilePopover) {
profilePopover.style.display = profilePopover.style.display === 'block' ? 'none' : 'block';
const expanded = profilePopover.style.display === 'block';
profileBtn.setAttribute('aria-expanded', expanded ? 'true' : 'false');
}
});
}

// Close popover when clicking outside
document.addEventListener('click', (e) => {
if (!profilePopover || !profileBtn) return;
if (!profilePopover.contains(e.target) && e.target !== profileBtn) {
profilePopover.style.display = 'none';
profileBtn.setAttribute('aria-expanded','false');
Expand All @@ -579,7 +590,9 @@ <h3 style="font-size:12px; font-weight:700; text-transform:uppercase; color:var(
if (e.target && e.target.id === 'popover-logout') {
localStorage.removeItem('studyplan_user');
document.getElementById('auth-modal').style.display = 'flex';
profilePopover.style.display = 'none';
if (profilePopover) {
profilePopover.style.display = 'none';
}
window.location.reload();
}
});
Expand Down
7 changes: 7 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ function formatDuration(mins) {
return `${mins} mins`;
}

function renderSummary() {
const summaryBox = document.getElementById('summary-box');
if (!summaryBox) return;
summaryBox.innerHTML = generateSummary(store.tasks, store.subjects);
}

let currentMonthDate = new Date();
let selectedDate = null;
let currentView = 'calendar'; // 'calendar', 'all-tasks', 'archived'
Expand Down Expand Up @@ -1814,6 +1820,7 @@ store.subscribe(renderFocusTasks);
store.subscribe(renderProfileSection);
store.subscribe(renderSidebarSubjects);
store.subscribe(renderStreak);
store.subscribe(renderSummary);

function updateSidebarActive(id) {
document.querySelectorAll('.sidebar .nav-item').forEach(el => el.classList.remove('active'));
Expand Down
13 changes: 0 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.