diff --git a/js/app.js b/js/app.js index 5dc8d87..3fe10d1 100644 --- a/js/app.js +++ b/js/app.js @@ -1,5 +1,4 @@ -const STORAGE_SAVE_KEY = "launchdesk-v1-items"; -const STORAGE_LOAD_KEY = "launchdesk-items-v1"; // Intentional bug: this key should match STORAGE_SAVE_KEY. +const STORAGE_KEY = "launchdesk-v1-items"; const demoChecks = [ { @@ -91,7 +90,7 @@ const activityLog = document.getElementById("activityLog"); let checks = loadChecks(); let currentView = checks; -form.addEventListener("submit", (event) => handleAddChek(event)); // Intentional bug: misspelled function name. +form.addEventListener("submit", (event) => handleAddCheck(event)); searchInput.addEventListener("input", applyFilters); statusFilter.addEventListener("change", applyFilters); priorityFilter.addEventListener("change", applyFilters); @@ -104,7 +103,7 @@ renderApp(); logActivity("Demo data loaded. Start by testing the checklist workflows."); function loadChecks() { - const saved = localStorage.getItem(STORAGE_LOAD_KEY); + const saved = localStorage.getItem(STORAGE_KEY); if (!saved) { return [...demoChecks]; @@ -119,7 +118,7 @@ function loadChecks() { } function saveChecks() { - localStorage.setItem(STORAGE_SAVE_KEY, JSON.stringify(checks)); + localStorage.setItem(STORAGE_KEY, JSON.stringify(checks)); } function handleAddCheck(event) { @@ -132,8 +131,7 @@ function handleAddCheck(event) { const owner = ownerInput.value.trim() || "Unassigned"; const dueDate = dueDateInput.value || new Date().toISOString().slice(0, 10); - if (!title && !category) { - // Intentional bug: validation should stop when either required field is missing. + if (!title || !category) { formMessage.textContent = "Please enter a check title and choose a category."; return; @@ -164,12 +162,16 @@ function applyFilters() { const selectedPriority = priorityFilter.value; let filtered = checks.filter((check) => - check.owner.toLowerCase().includes(searchTerm), - ); // Intentional bug: search should include title, category, priority, status, and owner. + check.owner.toLowerCase().includes(searchTerm) || + check.title.toLowerCase().includes(searchTerm) || + check.category.toLowerCase().includes(searchTerm) || + check.priority.toLowerCase().includes(searchTerm) || + check.status.toLowerCase().includes(searchTerm), + ); if (selectedStatus !== "All") { - filtered = filtered.filter((check) => check.priority === selectedStatus); - } // Intentional bug: status filter compares against priority. + filtered = filtered.filter((check) => check.status === selectedStatus); + } if (selectedPriority !== "All") { filtered = filtered.filter((check) => check.priority === selectedPriority); @@ -191,8 +193,7 @@ function renderRows(list) { const rows = list.map((check) => { const priorityClass = `priority-${check.priority.toLowerCase()}`; - const statusClass = `status-${check.status.toLowerCase()}`; // Intentional bug: "In Progress" needs a slug class. - + const statusClass = `status-${check.status.toLowerCase().replaceAll(" ", "-")}`; return `