-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathunits.js
More file actions
71 lines (58 loc) · 2.34 KB
/
Copy pathunits.js
File metadata and controls
71 lines (58 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Units overview page functionality
document.addEventListener('DOMContentLoaded', () => {
renderPeriodCards();
});
function renderPeriodCards() {
const grid = document.getElementById('units-grid');
if (!grid || !window.APUSH_DATA) return;
const progress = APUSH.getUserProgress();
Object.values(APUSH_DATA.periods).forEach(period => {
const card = createPeriodCard(period, progress);
grid.appendChild(card);
});
}
function createPeriodCard(period, progress) {
const card = document.createElement('div');
card.className = 'unit-card';
card.setAttribute('role', 'listitem');
card.setAttribute('tabindex', '0');
const periodProgress = progress.periods[period.number] || { mastery: 0, completed: false };
const masteryPercentage = periodProgress.mastery || 0;
// Difficulty badge
const difficultyClass = `difficulty-${period.difficulty}`;
const difficultyText = '★'.repeat(period.difficulty) + '☆'.repeat(5 - period.difficulty);
card.innerHTML = `
<div class="unit-card-header">
<div>
<h3 class="unit-card-title">Period ${period.number}: ${period.name}</h3>
<p class="unit-card-dates">${period.dates}</p>
</div>
<span class="difficulty-badge ${difficultyClass}">${difficultyText}</span>
</div>
<div class="unit-card-themes">
${period.themes.slice(0, 4).map(theme =>
`<span class="theme-tag">${theme}</span>`
).join('')}
</div>
<div class="unit-card-meta">
<span>${period.studyTime} min</span>
<span>${masteryPercentage}% Mastery</span>
</div>
<div class="unit-card-skills">
<p style="font-size: 0.875rem; color: var(--text-muted); margin-top: var(--spacing-md);">
Skills: ${period.skills.join(', ')}
</p>
</div>
`;
// Add click handler
card.addEventListener('click', () => {
window.location.href = `unit-study.html?period=${period.number}`;
});
card.addEventListener('keydown', (e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
window.location.href = `unit-study.html?period=${period.number}`;
}
});
return card;
}