JS Lab 3
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { students } from "./data.js";
|
||||
import { calculateOverallStatistics } from "./analytics.js";
|
||||
import { getTopThree, uniqueCourses } from "./utils.js";
|
||||
import { renderTable, renderSummary } from "./ui.js";
|
||||
import { toggleTheme, loadTheme } from "./theme.js";
|
||||
|
||||
let filteredStudents = [...students];
|
||||
|
||||
const nameSearchInput = document.getElementById("nameSearch");
|
||||
const minGradeInput = document.getElementById("minimumGrade");
|
||||
const minGradeValue = document.getElementById("gradeValue");
|
||||
|
||||
const applyFilters = () => {
|
||||
const nameFilter = nameSearchInput.value.toLowerCase();
|
||||
const minGrade = parseInt(minGradeInput.value);
|
||||
|
||||
filteredStudents = students.filter((student) => student.name.toLowerCase().includes(nameFilter) && student.grade >= minGrade);
|
||||
|
||||
const topThree = getTopThree(filteredStudents);
|
||||
renderTable(filteredStudents, topThree);
|
||||
|
||||
const stats = calculateOverallStatistics(filteredStudents);
|
||||
renderSummary(stats, uniqueCourses(filteredStudents).length);
|
||||
};
|
||||
|
||||
nameSearchInput.addEventListener("input", applyFilters);
|
||||
minGradeInput.addEventListener("input", () => {
|
||||
minGradeValue.textContent = minGradeInput.value;
|
||||
applyFilters();
|
||||
});
|
||||
|
||||
document.getElementById("themeToggle").addEventListener("click", toggleTheme);
|
||||
|
||||
loadTheme();
|
||||
applyFilters();
|
||||
Reference in New Issue
Block a user