Create a graduate milestone tracking
- User
Create a graduate milestone tracking system: candidacy, proposal, defense, leaves, and alerts.
Assistant
Create a graduate milestone tracking system: candidacy, proposal, defense, leaves, and alerts.
The user wants a graduate milestone tracking system with these features:
Let me create a sophisticated, visually striking single-page application that:
Design Direction:
Features:
Color scheme:
Let me build this comprehensively.
I'll create a sophisticated, professional tracking system with a distinctive academic aesthetic, featuring milestone management, deadline alerts, and student progress visualization.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GradTrack | Graduate Milestone System</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Sans:wght@400;500;600&display=swap" rel="stylesheet">
<style>
:root {
--bg: #0a0a0b;
--bg-elevated: #141416;
--bg-card: #1a1a1e;
--fg: #f5f5f4;
--fg-muted: #a1a1aa;
--accent: #d4a853;
--accent-dim: rgba(212, 168, 83, 0.15);
--danger: #ef4444;
--danger-dim: rgba(239, 68, 68, 0.15);
--success: #22c55e;
--success-dim: rgba(34, 197, 94, 0.15);
--warning: #f59e0b;
--warning-dim: rgba(245, 158, 11, 0.15);
--border: #27272a;
--border-subtle: #1f1f23;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'DM Sans', sans-serif;
background: var(--bg);
color: var(--fg);
min-height: 100vh;
overflow-x: hidden;
}
h1, h2, h3, h4, h5, h6 {
font-family: 'Space Grotesk', sans-serif;
}
/* Background pattern */
.bg-pattern {
position: fixed;
inset: 0;
background-image:
radial-gradient(circle at 20% 20%, rgba(212, 168, 83, 0.03) 0%, transparent 50%),
radial-gradient(circle at 80% 80%, rgba(212, 168, 83, 0.02) 0%, transparent 50%);
pointer-events: none;
z-index: 0;
}
.bg-grid {
position: fixed;
inset: 0;
background-image:
linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
background-size: 60px 60px;
pointer-events: none;
z-index: 0;
}
/* Scrollbar */
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-track {
background: var(--bg);
}
::-webkit-scrollbar-thumb {
background: var(--border);
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--fg-muted);
}
/* Animations */
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes slideInLeft {
from {
opacity: 0;
transform: translateX(-20px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
@keyframes pulse-glow {
0%, 100% { box-shadow: 0 0 0 0 var(--accent-dim); }
50% { box-shadow: 0 0 20px 5px var(--accent-dim); }
}
@keyframes shake {
0%, 100% { transform: translateX(0); }
25% { transform: translateX(-2px); }
75% { transform: translateX(2px); }
}
.animate-fade-in {
animation: fadeInUp 0.5s ease-out forwards;
}
.animate-slide-in {
animation: slideInLeft 0.4s ease-out forwards;
}
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
/* Card styles */
.card {
background: var(--bg-card);
border: 1px solid var(--border-subtle);
border-radius: 12px;
transition: all 0.2s ease;
}
.card:hover {
border-color: var(--border);
transform: translateY(-2px);
}
/* Status badges */
.status-badge {
padding: 4px 10px;
border-radius: 6px;
font-size: 12px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.status-completed {
background: var(--success-dim);
color: var(--success);
}
.status-in-progress {
background: var(--accent-dim);
color: var(--accent);
}
.status-pending {
background: rgba(161, 161, 170, 0.15);
color: var(--fg-muted);
}
.status-overdue {
background: var(--danger-dim);
color: var(--danger);
animation: shake 0.5s ease-in-out infinite;
}
/* Progress bar */
.progress-track {
height: 6px;
background: var(--border);
border-radius: 3px;
overflow: hidden;
}
.progress-fill {
height: 100%;
background: linear-gradient(90deg, var(--accent), #e8c477);
border-radius: 3px;
transition: width 0.5s ease-out;
}
/* Button styles */
.btn-primary {
background: var(--accent);
color: var(--bg);
padding: 10px 20px;
border-radius: 8px;
font-weight: 600;
font-family: 'Space Grotesk', sans-serif;
border: none;
cursor: pointer;
transition: all 0.2s ease;
}
.btn-primary:hover {
background: #e8c477;
transform: translateY(-1px);
}
.btn-primary:active {
transform: translateY(0);
}
.btn-primary:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.btn-ghost {
background: transparent;
color: var(--fg-muted);
padding: 8px 16px;
border-radius: 6px;
font-weight: 500;
border: 1px solid var(--border);
cursor: pointer;
transition: all 0.2s ease;
}
.btn-ghost:hover {
background: var(--bg-elevated);
color: var(--fg);
border-color: var(--border);
}
/* Input styles */
.input-field {
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
padding: 10px 14px;
color: var(--fg);
font-family: 'DM Sans', sans-serif;
transition: all 0.2s ease;
width: 100%;
}
.input-field:focus {
outline: none;
border-color: var(--accent);
box-shadow: 0 0 0 3px var(--accent-dim);
}
.input-field::placeholder {
color: var(--fg-muted);
}
/* Timeline */
.timeline-node {
position: relative;
padding-left: 32px;
}
.timeline-node::before {
content: '';
position: absolute;
left: 8px;
top: 28px;
bottom: -12px;
width: 2px;
background: var(--border);
}
.timeline-node:last-child::before {
display: none;
}
.timeline-dot {
position: absolute;
left: 0;
top: 6px;
width: 18px;
height: 18px;
border-radius: 50%;
border: 2px solid var(--border);
background: var(--bg-card);
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
}
.timeline-dot.completed {
background: var(--success);
border-color: var(--success);
}
.timeline-dot.active {
border-color: var(--accent);
box-shadow: 0 0 0 4px var(--accent-dim);
}
/* Alert animation */
.alert-badge {
position: absolute;
top: -4px;
right: -4px;
width: 18px;
height: 18px;
background: var(--danger);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 10px;
font-weight: 700;
animation: pulse-glow 2s infinite;
}
/* Modal */
.modal-overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.8);
backdrop-filter: blur(4px);
z-index: 50;
display: none;
align-items: center;
justify-content: center;
padding: 20px;
}
.modal-overlay.active {
display: flex;
}
.modal-content {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: 16px;
max-width: 500px;
width: 100%;
max-height: 90vh;
overflow-y: auto;
animation: fadeInUp 0.3s ease-out;
}
/* Tab styles */
.tab-btn {
padding: 12px 20px;
font-weight: 500;
color: var(--fg-muted);
background: transparent;
border: none;
border-bottom: 2px solid transparent;
cursor: pointer;
transition: all 0.2s ease;
font-family: 'DM Sans', sans-serif;
}
.tab-btn:hover {
color: var(--fg);
}
.tab-btn.active {
color: var(--accent);
border-bottom-color: var(--accent);
}
.tab-content {
display: none;
}
.tab-content.active {
display: block;
}
/* Filter pills */
.filter-pill {
padding: 6px 14px;
border-radius: 20px;
font-size: 13px;
font-weight: 500;
background: var(--bg-elevated);
color: var(--fg-muted);
border: 1px solid var(--border);
cursor: pointer;
transition: all 0.2s ease;
}
.filter-pill:hover {
border-color: var(--fg-muted);
}
.filter-pill.active {
background: var(--accent-dim);
color: var(--accent);
border-color: var(--accent);
}
/* Leave status indicator */
.leave-indicator {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 4px 10px;
border-radius: 4px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
}
.leave-active {
background: var(--warning-dim);
color: var(--warning);
}
.leave-scheduled {
background: rgba(59, 130, 246, 0.15);
color: #60a5fa;
}
</style>
</head>
<body>
<div class="bg-pattern"></div>
<div class="bg-grid"></div>
<div class="relative z-10 min-h-screen">
<!-- Header -->
<header class="border-b border-[var(--border)] bg-[var(--bg-elevated)]/80 backdrop-blur-md sticky top-0 z-40">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex items-center justify-between h-16">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-lg bg-gradient-to-br from-[var(--accent)] to-[#b8923d] flex items-center justify-center">
<svg class="w-5 h-5 text-[var(--bg)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 14l9-5-9-5-9 5 9 5z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 14l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 14l9-5-9-5-9 5 9 5zm0 0l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14zm-4 6v-7.5l4-2.222"/>
</svg>
</div>
<div>
<h1 class="text-lg font-bold tracking-tight">GradTrack</h1>
<p class="text-xs text-[var(--fg-muted)]">Milestone Tracking System</p>
</div>
</div>
<div class="flex items-center gap-4">
<!-- Search -->
<div class="hidden sm:block relative">
<input
type="text"
id="searchInput"
placeholder="Search students..."
class="input-field w-64 pl-10"
>
<svg class="w-4 h-4 text-[var(--fg-muted)] absolute left-3 top-1/2 -translate-y-1/2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
</div>
<!-- Alerts Bell -->
<button id="alertsBtn" class="relative p-2 rounded-lg hover:bg-[var(--bg)] transition-colors" aria-label="View alerts">
<svg class="w-5 h-5 text-[var(--fg-muted)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"/>
</svg>
<span id="alertCount" class="alert-badge hidden">0</span>
</button>
<!-- Add Student -->
<button id="addStudentBtn" class="btn-primary flex items-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
</svg>
<span class="hidden sm:inline">Add Student</span>
</button>
</div>
</div>
</div>
</header>
<!-- Main Content -->
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<!-- Stats Overview -->
<section class="grid grid-cols-2 lg:grid-cols-5 gap-4 mb-8 opacity-0 animate-fade-in" style="animation-delay: 0.1s;">
<div class="card p-5">
<p class="text-[var(--fg-muted)] text-sm mb-1">Total Students</p>
<p class="text-3xl font-bold" id="statTotal">0</p>
</div>
<div class="card p-5">
<p class="text-[var(--fg-muted)] text-sm mb-1">Candidacy Passed</p>
<p class="text-3xl font-bold text-[var(--success)]" id="statCandidacy">0</p>
</div>
<div class="card p-5">
<p class="text-[var(--fg-muted)] text-sm mb-1">Proposal Done</p>
<p class="text-3xl font-bold text-[var(--accent)]" id="statProposal">0</p>
</div>
<div class="card p-5">
<p class="text-[var(--fg-muted)] text-sm mb-1">Defended</p>
<p class="text-3xl font-bold text-[var(--accent)]" id="statDefense">0</p>
</div>
<div class="card p-5 col-span-2 lg:col-span-1">
<p class="text-[var(--fg-muted)] text-sm mb-1">On Leave</p>
<p class="text-3xl font-bold text-[var(--warning)]" id="statLeave">0</p>
</div>
</section>
<!-- Tabs -->
<div class="border-b border-[var(--border)] mb-6 opacity-0 animate-fade-in" style="animation-delay: 0.2s;">
<nav class="flex gap-1 overflow-x-auto">
<button class="tab-btn active" data-tab="students">All Students</button>
<button class="tab-btn" data-tab="timeline">Timeline View</button>
<button class="tab-btn" data-tab="leaves">Leave Management</button>
</nav>
</div>
<!-- Filters -->
<div class="flex flex-wrap gap-2 mb-6 opacity-0 animate-fade-in" style="animation-delay: 0.25s;" id="filterContainer">
<button class="filter-pill active" data-filter="all">All</button>
<button class="filter-pill" data-filter="overdue">Overdue</button>
<button class="filter-pill" data-filter="candidacy">Candidacy</button>
<button class="filter-pill" data-filter="proposal">Proposal</button>
<button class="filter-pill" data-filter="defense">Defense</button>
<button class="filter-pill" data-filter="leave">On Leave</button>
</div>
<!-- Tab Content: Students -->
<div id="tab-students" class="tab-content active">
<div id="studentsGrid" class="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
<!-- Cards rendered by JS -->
</div>
</div>
<!-- Tab Content: Timeline -->
<div id="tab-timeline" class="tab-content">
<div id="timelineView" class="space-y-6">
<!-- Timeline rendered by JS -->
</div>
</div>
<!-- Tab Content: Leaves -->
<div id="tab-leaves" class="tab-content">
<div id="leavesView" class="space-y-4">
<!-- Leaves rendered by JS -->
</div>
</div>
</main>
</div>
<!-- Add Student Modal -->
<div id="addStudentModal" class="modal-overlay" role="dialog" aria-modal="true" aria-labelledby="modalTitle">
<div class="modal-content">
<div class="p-6 border-b border-[var(--border)]">
<div class="flex items-center justify-between">
<h2 id="modalTitle" class="text-xl font-bold">Add New Student</h2>
<button id="closeModal" class="p-2 hover:bg-[var(--bg)] rounded-lg transition-colors" aria-label="Close modal">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
</svg>
</button>
</div>
</div>
<form id="addStudentForm" class="p-6 space-y-4">
<div>
<label class="block text-sm font-medium mb-2">Full Name</label>
<input type="text" name="name" class="input-field" placeholder="e.g., Jane Smith" required>
</div>
<div>
<label class="block text-sm font-medium mb-2">Program</label>
<select name="program" class="input-field" required>
<option value="">Select program...</option>
<option value="PhD Computer Science">PhD Computer Science</option>
<option value="PhD Mathematics">PhD Mathematics</option>
<option value="PhD Physics">PhD Physics</option>
<option value="PhD Engineering">PhD Engineering</option>
<option value="PhD Biology">PhD Biology</option>
<option value="MS Computer Science">MS Computer Science</option>
<option value="MS Data Science">MS Data Science</option>
</select>
</div>
<div>
<label class="block text-sm font-medium mb-2">Advisor</label>
<input type="text" name="advisor" class="input-field" placeholder="e.g., Dr. Johnson">
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium mb-2">Start Date</label>
<input type="date" name="startDate" class="input-field" required>
</div>
<div>
<label class="block text-sm font-medium mb-2">Expected Graduation</label>
<input type="date" name="expectedGrad" class="input-field" required>
</div>
</div>
<div class="pt-4 flex gap-3">
<button type="button" id="cancelBtn" class="btn-ghost flex-1">Cancel</button>
<button type="submit" class="btn-primary flex-1">Add Student</button>
</div>
</form>
</div>
</div>
<!-- Alerts Panel -->
<div id="alertsPanel" class="fixed inset-y-0 right-0 w-full max-w-md bg-[var(--bg-card)] border-l border-[var(--border)] transform translate-x-full transition-transform duration-300 z-50 overflow-hidden flex flex-col">
<div class="p-6 border-b border-[var(--border)] flex items-center justify-between">
<h2 class="text-xl font-bold">Alerts</h2>
<button id="closeAlerts" class="p-2 hover:bg-[var(--bg)] rounded-lg transition-colors" aria-label="Close alerts">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
</svg>
</button>
</div>
<div id="alertsList" class="flex-1 overflow-y-auto p-4 space-y-3">
<!-- Alerts rendered by JS -->
</div>
</div>
<!-- Student Detail Modal -->
<div id="studentDetailModal" class="modal-overlay" role="dialog" aria-modal="true">
<div class="modal-content max-w-2xl">
<div class="p-6 border-b border-[var(--border)]">
<div class="flex items-center justify-between">
<h2 id="studentDetailName" class="text-xl font-bold">Student Name</h2>
<button id="closeStudentDetail" class="p-2 hover:bg-[var(--bg)] rounded-lg transition-colors" aria-label="Close">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
</svg>
</button>
</div>
</div>
<div id="studentDetailContent" class="p-6">
<!-- Detail content rendered by JS -->
</div>
</div>
</div>
<script>
// Data Store
let students = [
{
id: 1,
name: 'Alexandra Chen',
program: 'PhD Computer Science',
advisor: 'Dr. Sarah Mitchell',
startDate: '2022-09-01',
expectedGrad: '2027-05-15',
milestones: {
candidacy: { status: 'completed', date: '2023-03-15', targetDate: '2023-04-01' },
proposal: { status: 'completed', date: '2023-11-20', targetDate: '2023-12-01' },
defense: { status: 'pending', date: null, targetDate: '2026-12-01' }
},
leave: null
},
{
id: 2,
name: 'Marcus Johnson',
program: 'PhD Mathematics',
advisor: 'Dr. Robert Klein',
startDate: '2021-09-01',
expectedGrad: '2026-05-15',
milestones: {
candidacy: { status: 'completed', date: '2022-03-10', targetDate: '2022-04-01' },
proposal: { status: 'completed', date: '2023-01-15', targetDate: '2023-02-01' },
defense: { status: 'in-progress', date: null, targetDate: '2025-12-01' }
},
leave: { type: 'medical', startDate: '2024-01-15', endDate: '2024-04-15', status: 'active' }
},
{
id: 3,
name: 'Priya Sharma',
program: 'PhD Engineering',
advisor: 'Dr. James Wilson',
startDate: '2023-01-15',
expectedGrad: '2027-08-01',
milestones: {
candidacy: { status: 'in-progress', date: null, targetDate: '2024-04-01' },
proposal: { status: 'pending', date: null, targetDate: '2025-01-01' },
defense: { status: 'pending', date: null, targetDate: '2027-04-01' }
},
leave: null
},
{
id: 4,
name: 'David Park',
program: 'MS Data Science',
advisor: 'Dr. Lisa Chang',
startDate: '2023-09-01',
expectedGrad: '2025-05-15',
milestones: {
candidacy: { status: 'completed', date: '2024-01-10', targetDate: '2024-02-01' },
proposal: { status: 'overdue', date: null, targetDate: '2024-03-01' },
defense: { status: 'pending', date: null, targetDate: '2025-03-01' }
},
leave: null
},
{
id: 5,
name: 'Emma Rodriguez',
program: 'PhD Biology',
advisor: 'Dr. Maria Santos',
startDate: '2020-09-01',
expectedGrad: '2025-08-01',
milestones: {
candidacy: { status: 'completed', date: '2021-03-20', targetDate: '2021-04-01' },
proposal: { status: 'completed', date: '2022-02-15', targetDate: '2022-03-01' },
defense: { status: 'in-progress', date: null, targetDate: '2025-02-01' }
},
leave: { type: 'personal', startDate: '2024-06-01', endDate: '2024-08-01', status: 'scheduled' }
},
{
id: 6,
name: 'Thomas Wright',
program: 'PhD Physics',
advisor: 'Dr. Alan Green',
startDate: '2022-01-15',
expectedGrad: '2027-01-15',
milestones: {
candidacy: { status: 'overdue', date: null, targetDate: '2024-01-01' },
proposal: { status: 'pending', date: null, targetDate: '2025-01-01' },
defense: { status: 'pending', date: null, targetDate: '2026-09-01' }
},
leave: null
}
];
let currentFilter = 'all';
let searchQuery = '';
// DOM Elements - Initialize after DOM is ready
let searchInput, addStudentBtn, addStudentModal, closeModalBtn, cancelBtn;
let addStudentForm, alertsBtn, alertsPanel, closeAlerts, alertCount;
let studentDetailModal, closeStudentDetail, studentsGrid, timelineView, leavesView;
let alertsList, filterContainer, tabBtns;
// Initialize DOM elements
function initDOMElements() {
searchInput = document.getElementById('searchInput');
addStudentBtn = document.getElementById('addStudentBtn');
addStudentModal = document.getElementById('addStudentModal');
closeModalBtn = document.getElementById('closeModal');
cancelBtn = document.getElementById('cancelBtn');
addStudentForm = document.getElementById('addStudentForm');
alertsBtn = document.getElementById('alertsBtn');
alertsPanel = document.getElementById('alertsPanel');
closeAlerts = document.getElementById('closeAlerts');
alertCount = document.getElementById('alertCount');
studentDetailModal = document.getElementById('studentDetailModal');
closeStudentDetail = document.getElementById('closeStudentDetail');
studentsGrid = document.getElementById('studentsGrid');
timelineView = document.getElementById('timelineView');
leavesView = document.getElementById('leavesView');
alertsList = document.getElementById('alertsList');
filterContainer = document.getElementById('filterContainer');
tabBtns = document.querySelectorAll('.tab-btn');
}
// Utility Functions
function formatDate(dateStr) {
if (!dateStr) return 'Not set';
const date = new Date(dateStr);
return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });
}
function getDaysUntil(dateStr) {
if (!dateStr) return null;
const target = new Date(dateStr);
const today = new Date();
const diff = Math.ceil((target - today) / (1000 * 60 * 60 * 24));
return diff;
}
function getStatusClass(status) {
const classes = {
'completed': 'status-completed',
'in-progress': 'status-in-progress',
'pending': 'status-pending',
'overdue': 'status-overdue'
};
return classes[status] || 'status-pending';
}
function getProgress(student) {
const milestones = Object.values(student.milestones);
const completed = milestones.filter(m => m.status === 'completed').length;
return Math.round((completed / milestones.length) * 100);
}
// Render Functions
function renderStudentCard(student, index) {
const progress = getProgress(student);
const currentMilestone = Object.entries(student.milestones)
.find(([_, m]) => m.status === 'in-progress' || m.status === 'overdue');
const milestoneLabels = {
candidacy: 'Candidacy Exam',
proposal: 'Proposal Defense',
defense: 'Final Defense'
};
let leaveIndicator = '';
if (student.leave) {
leaveIndicator = `
<span class="leave-indicator ${student.leave.status === 'active' ? 'leave-active' : 'leave-scheduled'}">
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
${student.leave.status === 'active' ? 'On Leave' : 'Leave Scheduled'}
</span>
`;
}
const currentMilestoneDisplay = currentMilestone
? `<span class="status-badge ${getStatusClass(currentMilestone[1].status)}">${milestoneLabels[currentMilestone[0]]}</span>`
: '<span class="status-badge status-completed">All Complete</span>';
return `
<article class="card p-5 cursor-pointer opacity-0 animate-fade-in stagger-${(index % 5) + 1}"
onclick="openStudentDetail(${student.id})"
tabindex="0"
role="button"
aria-label="View details for ${student.name}">
<div class="flex items-start justify-between mb-4">
<div>
<h3 class="font-semibold text-lg">${student.name}</h3>
<p class="text-sm text-[var(--fg-muted)]">${student.program}</p>
</div>
${leaveIndicator}
</div>
<div class="mb-4">
<div class="flex justify-between text-sm mb-2">
<span class="text-[var(--fg-muted)]">Progress</span>
<span class="font-medium">${progress}%</span>
</div>
<div class="progress-track">
<div class="progress-fill" style="width: ${progress}%"></div>
</div>
</div>
<div class="flex items-center justify-between">
${currentMilestoneDisplay}
<span class="text-xs text-[var(--fg-muted)]">Grad: ${formatDate(student.expectedGrad)}</span>
</div>
</article>
`;
}
function renderTimeline() {
const sortedStudents = [...students].sort((a, b) =>
new Date(a.expectedGrad) - new Date(b.expectedGrad)
);
let html = '';
sortedStudents.forEach((student, idx) => {
const milestoneLabels = {
candidacy: 'Candidacy Exam',
proposal: 'Proposal Defense',
defense: 'Final Defense'
};
html += `
<div class="card p-6 opacity-0 animate-fade-in" style="animation-delay: ${idx * 0.1}s;">
<div class="flex items-center justify-between mb-6">
<div>
<h3 class="font-semibold text-lg">${student.name}</h3>
<p class="text-sm text-[var(--fg-muted)]">${student.program} • ${student.advisor}</p>
</div>
<div class="text-right">
<p class="text-sm text-[var(--fg-muted)]">Expected Graduation</p>
<p class="font-medium">${formatDate(student.expectedGrad)}</p>
</div>
</div>
<div class="space-y-4">
${Object.entries(student.milestones).map(([key, milestone]) => `
<div class="timeline-node">
<div class="timeline-dot ${milestone.status === 'completed' ? 'completed' : ''} ${milestone.status === 'in-progress' ? 'active' : ''}">
${milestone.status === 'completed' ? '<svg class="w-3 h-3 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M5 13l4 4L19 7"/></svg>' : ''}
</div>
<div class="flex items-center justify-between">
<div>
<p class="font-medium">${milestoneLabels[key]}</p>
<p class="text-sm text-[var(--fg-muted)]">
${milestone.date ? `Completed: ${formatDate(milestone.date)}` : `Target: ${formatDate(milestone.targetDate)}`}
</p>
</div>
<span class="status-badge ${getStatusClass(milestone.status)}">${milestone.status}</span>
</div>
</div>
`).join('')}
</div>
</div>
`;
});
timelineView.innerHTML = html;
}
function renderLeaves() {
const studentsWithLeave = students.filter(s => s.leave);
if (studentsWithLeave.length === 0) {
leavesView.innerHTML = `
<div class="card p-12 text-center">
<svg class="w-16 h-16 mx-auto mb-4 text-[var(--fg-muted)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
</svg>
<p class="text-[var(--fg-muted)]">No students currently on leave</p>
</div>
`;
return;
}
let html = '';
studentsWithLeave.forEach((student, idx) => {
html += `
<div class="card p-5 opacity-0 animate-fade-in" style="animation-delay: ${idx * 0.1}s;">
<div class="flex items-center justify-between mb-4">
<div>
<h3 class="font-semibold">${student.name}</h3>
<p class="text-sm text-[var(--fg-muted)]">${student.program}</p>
</div>
<span class="status-badge ${student.leave.status === 'active' ? 'status-overdue' : 'status-in-progress'}">
${student.leave.status === 'active' ? 'Active Leave' : 'Scheduled'}
</span>
</div>
<div class="grid grid-cols-3 gap-4 text-sm">
<div>
<p class="text-[var(--fg-muted)] mb-1">Type</p>
<p class="capitalize font-medium">${student.leave.type}</p>
</div>
<div>
<p class="text-[var(--fg-muted)] mb-1">Start Date</p>
<p class="font-medium">${formatDate(student.leave.startDate)}</p>
</div>
<div>
<p class="text-[var(--fg-muted)] mb-1">End Date</p>
<p class="font-medium">${formatDate(student.leave.endDate)}</p>
</div>
</div>
</div>
`;
});
leavesView.innerHTML = html;
}
function renderAlerts() {
const alerts = [];
students.forEach(student => {
Object.entries(student.milestones).forEach(([key, milestone]) => {
if (milestone.status === 'overdue') {
const days = Math.abs(getDaysUntil(milestone.targetDate));
alerts.push({
type: 'overdue',
student: student.name,
studentId: student.id,
milestone: key,
message: `${key.charAt(0).toUpperCase() + key.slice(1)} overdue by ${days} days`,
severity: 'high'
});
} else if (milestone.status === 'in-progress' || milestone.status === 'pending') {
const days = getDaysUntil(milestone.targetDate);
if (days !== null && days <= 30 && days > 0) {
alerts.push({
type: 'upcoming',
student: student.name,
studentId: student.id,
milestone: key,
message: `${key.charAt(0).toUpperCase() + key.slice(1)} due in ${days} days`,
severity: days <= 7 ? 'high' : 'medium'
});
}
}
});
if (student.leave && student.leave.status === 'active') {
const daysRemaining = getDaysUntil(student.leave.endDate);
if (daysRemaining !== null && daysRemaining <= 14) {
alerts.push({
type: 'leave',
student: student.name,
studentId: student.id,
message: `Leave ending in ${daysRemaining} days`,
severity: 'medium'
});
}
}
});
// Sort by severity
alerts.sort((a, b) => {
const severityOrder = { high: 0, medium: 1, low: 2 };
return severityOrder[a.severity] - severityOrder[b.severity];
});
// Update alert count
if (alerts.length > 0) {
alertCount.textContent = alerts.length;
alertCount.classList.remove('hidden');
} else {
alertCount.classList.add('hidden');
}
// Render alerts list
if (alerts.length === 0) {
alertsList.innerHTML = `
<div class="text-center py-12">
<svg class="w-16 h-16 mx-auto mb-4 text-[var(--success)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
<p class="text-[var(--fg-muted)]">All caught up! No alerts.</p>
</div>
`;
return;
}
alertsList.innerHTML = alerts.map(alert => `
<div class="p-4 rounded-lg ${alert.severity === 'high' ? 'bg-[var(--danger-dim)]' : 'bg-[var(--warning-dim)]'} cursor-pointer hover:opacity-80 transition-opacity"
onclick="openStudentDetail(${alert.studentId}); closeAlertsPanel();">
<div class="flex items-start gap-3">
<div class="p-2 rounded-lg ${alert.severity === 'high' ? 'bg-[var(--danger)]/20' : 'bg-[var(--warning)]/20'}">
${alert.type === 'overdue' ? `
<svg class="w-4 h-4 text-[var(--danger)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
` : `
<svg class="w-4 h-4 text-[var(--warning)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
`}
</div>
<div>
<p class="font-medium text-sm">${alert.student}</p>
<p class="text-sm opacity-80">${alert.message}</p>
</div>
</div>
</div>
`).join('');
}
function renderStats() {
document.getElementById('statTotal').textContent = students.length;
document.getElementById('statCandidacy').textContent = students.filter(s => s.milestones.candidacy.status === 'completed').length;
document.getElementById('statProposal').textContent = students.filter(s => s.milestones.proposal.status === 'completed').length;
document.getElementById('statDefense').textContent = students.filter(s => s.milestones.defense.status === 'completed').length;
document.getElementById('statLeave').textContent = students.filter(s => s.leave).length;
}
function filterStudents() {
let filtered = [...students];
// Apply search
if (searchQuery) {
const query = searchQuery.toLowerCase();
filtered = filtered.filter(s =>
s.name.toLowerCase().includes(query) ||
s.program.toLowerCase().includes(query) ||
s.advisor.toLowerCase().includes(query)
);
}
// Apply filter
switch (currentFilter) {
case 'overdue':
filtered = filtered.filter(s =>
Object.values(s.milestones).some(m => m.status === 'overdue')
);
break;
case 'candidacy':
filtered = filtered.filter(s =>
s.milestones.candidacy.status === 'in-progress' || s.milestones.candidacy.status === 'overdue'
);
break;
case 'proposal':
filtered = filtered.filter(s =>
s.milestones.proposal.status === 'in-progress' || s.milestones.proposal.status === 'overdue'
);
break;
case 'defense':
filtered = filtered.filter(s =>
s.milestones.defense.status === 'in-progress' || s.milestones.defense.status === 'overdue'
);
break;
case 'leave':
filtered = filtered.filter(s => s.leave);
break;
}
return filtered;
}
function renderAll() {
const filtered = filterStudents();
studentsGrid.innerHTML = filtered.map((s, i) => renderStudentCard(s, i)).join('');
renderTimeline();
renderLeaves();
renderAlerts();
renderStats();
}
// Modal Functions
function openModal() {
addStudentModal.classList.add('active');
document.body.style.overflow = 'hidden';
addStudentForm.querySelector('input').focus();
}
function closeModal() {
addStudentModal.classList.remove('active');
document.body.style.overflow = '';
addStudentForm.reset();
}
function openStudentDetail(studentId) {
const student = students.find(s => s.id === studentId);
if (!student) return;
document.getElementById('studentDetailName').textContent = student.name;
const progress = getProgress(student);
const milestoneLabels = {
candidacy: 'Candidacy Exam',
proposal: 'Proposal Defense',
defense: 'Final Defense'
};
let leaveSection = '';
if (student.leave) {
leaveSection = `
<div class="mt-6 p-4 rounded-lg bg-[var(--warning-dim)]">
<h4 class="font-semibold mb-2 flex items-center gap-2">
<svg class="w-4 h-4 text-[var(--warning)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
Leave Information
</h4>
<p class="text-sm">Type: <span class="capitalize">${student.leave.type}</span></p>
<p class="text-sm">Duration: ${formatDate(student.leave.startDate)} - ${formatDate(student.leave.endDate)}</p>
<p class="text-sm">Status: <span class="capitalize">${student.leave.status}</span></p>
</div>
`;
}
document.getElementById('studentDetailContent').innerHTML = `
<div class="space-y-6">
<div class="grid grid-cols-2 gap-4">
<div>
<p class="text-sm text-[var(--fg-muted)]">Program</p>
<p class="font-medium">${student.program}</p>
</div>
<div>
<p class="text-sm text-[var(--fg-muted)]">Advisor</p>
<p class="font-medium">${student.advisor}</p>
</div>
<div>
<p class="text-sm text-[var(--fg-muted)]">Start Date</p>
<p class="font-medium">${formatDate(student.startDate)}</p>
</div>
<div>
<p class="text-sm text-[var(--fg-muted)]">Expected Graduation</p>
<p class="font-medium">${formatDate(student.expectedGrad)}</p>
</div>
</div>
<div>
<div class="flex justify-between text-sm mb-2">
<span class="text-[var(--fg-muted)]">Overall Progress</span>
<span class="font-medium">${progress}%</span>
</div>
<div class="progress-track">
<div class="progress-fill" style="width: ${progress}%"></div>
</div>
</div>
<div>
<h4 class="font-semibold mb-4">Milestones</h4>
<div class="space-y-4">
${Object.entries(student.milestones).map(([key, m]) => `
<div class="flex items-center justify-between p-4 rounded-lg bg-[var(--bg)]">
<div>
<p class="font-medium">${milestoneLabels[key]}</p>
<p class="text-sm text-[var(--fg-muted)]">
${m.date ? `Completed: ${formatDate(m.date)}` : `Target: ${formatDate(m.targetDate)}`}
</p>
</div>
<span class="status-badge ${getStatusClass(m.status)}">${m.status}</span>
</div>
`).join('')}
</div>
</div>
${leaveSection}
</div>
`;
studentDetailModal.classList.add('active');
document.body.style.overflow = 'hidden';
}
function closeStudentDetailModal() {
studentDetailModal.classList.remove('active');
document.body.style.overflow = '';
}
function openAlertsPanel() {
alertsPanel.style.transform = 'translateX(0)';
}
function closeAlertsPanel() {
alertsPanel.style.transform = 'translateX(100%)';
}
// Event Handlers
function handleAddStudent(e) {
e.preventDefault();
const formData = new FormData(e.target);
const newStudent = {
id: Date.now(),
name: formData.get('name'),
program: formData.get('program'),
advisor: formData.get('advisor') || 'TBD',
startDate: formData.get('startDate'),
expectedGrad: formData.get('expectedGrad'),
milestones: {
candidacy: { status: 'pending', date: null, targetDate: '' },
proposal: { status: 'pending', date: null, targetDate: '' },
defense: { status: 'pending', date: null, targetDate: '' }
},
leave: null
};
// Set default target dates based on start date
const startDate = new Date(newStudent.startDate);
const candidacyTarget = new Date(startDate);
candidacyTarget.setMonth(candidacyTarget.getMonth() + 18);
newStudent.milestones.candidacy.targetDate = candidacyTarget.toISOString().split('T')[0];
const proposalTarget = new Date(startDate);
proposalTarget.setMonth(proposalTarget.getMonth() + 30);
newStudent.milestones.proposal.targetDate = proposalTarget.toISOString().split('T')[0];
const defenseTarget = new Date(newStudent.expectedGrad);
defenseTarget.setMonth(defenseTarget.getMonth() - 3);
newStudent.milestones.defense.targetDate = defenseTarget.toISOString().split('T')[0];
students.push(newStudent);
renderAll();
closeModal();
}
function handleTabClick(e) {
const tab = e.target.dataset.tab;
if (!tab) return;
tabBtns.forEach(btn => btn.classList.remove('active'));
e.target.classList.add('active');
document.querySelectorAll('.tab-content').forEach(content => {
content.classList.remove('active');
});
document.getElementById(`tab-${tab}`).classList.add('active');
// Show/hide filters based on tab
filterContainer.style.display = tab === 'students' ? 'flex' : 'none';
}
function handleFilterClick(e) {
const filter = e.target.dataset.filter;
if (!filter) return;
document.querySelectorAll('.filter-pill').forEach(pill => pill.classList.remove('active'));
e.target.classList.add('active');
currentFilter = filter;
renderAll();
}
// Initialize
document.addEventListener('DOMContentLoaded', () => {
// Initialize DOM elements first
initDOMElements();
// Event Listeners
addStudentBtn.addEventListener('click', openModal);
closeModalBtn.addEventListener('click', closeModal);
cancelBtn.addEventListener('click', closeModal);
addStudentForm.addEventListener('submit', handleAddStudent);
alertsBtn.addEventListener('click', openAlertsPanel);
closeAlerts.addEventListener('click', closeAlertsPanel);
closeStudentDetail.addEventListener('click', closeStudentDetailModal);
// Tab navigation
tabBtns.forEach(btn => btn.addEventListener('click', handleTabClick));
// Filters
filterContainer.addEventListener('click', handleFilterClick);
// Search
searchInput.addEventListener('input', (e) => {
searchQuery = e.target.value;
renderAll();
});
// Close modals on overlay click
addStudentModal.addEventListener('click', (e) => {
if (e.target === addStudentModal) closeModal();
});
studentDetailModal.addEventListener('click', (e) => {
if (e.target === studentDetailModal) closeStudentDetailModal();
});
// Keyboard navigation
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
closeModal();
closeStudentDetailModal();
closeAlertsPanel();
}
});
// Card keyboard activation
studentsGrid.addEventListener('keydown', (e) => {
if (e.key === 'Enter' && e.target.classList.contains('card')) {
e.target.click();
}
});
// Initial render
renderAll();
});
</script>
</body>
</html>
prefers-reduced-motion