remove redundant button

This commit is contained in:
Joey Yakimowich-Payne 2025-04-18 07:15:22 -06:00
commit 3a18609e33
No known key found for this signature in database
GPG key ID: 6BFE655FA5ABD1E1
3 changed files with 29 additions and 6 deletions

View file

@ -806,6 +806,11 @@ function randomizeBoard() {
applyMarkedCellStyle(cell); // Reset marked styles (which also calls applyCellStyle)
});
// Explicitly remove any existing highlights BEFORE clearing the search input
const currentlyHighlighted = board.querySelectorAll('.bingo-cell.highlighted');
currentlyHighlighted.forEach(cell => cell.classList.remove('highlighted'));
clearSearch(); // Clear search highlights and input
clearMarks(false); // Clear visual marks
saveBoardState(); // Save the new randomized state (including cleared marks)
showNotification('Board randomized!', 'success');
@ -930,6 +935,22 @@ function getMarkedIndices() {
return indices;
}
// --- Clear Search Input and Highlights ---
function clearSearch() {
const searchInput = document.getElementById('search-input');
if (searchInput) {
searchInput.value = ''; // Clear the input field
// Trigger the input event listener to ensure highlights are removed
searchInput.dispatchEvent(new Event('input'));
}
// It's technically redundant to remove the class here now, as the
// event listener triggered above should handle it, but it doesn't hurt.
const highlightedCells = document.querySelectorAll('#bingo-board .bingo-cell.highlighted');
highlightedCells.forEach(cell => {
cell.classList.remove('highlighted'); // Remove highlight class
});
}
// --- Load State on Page Load ---
function loadFromLocalStorage() {
const savedSize = localStorage.getItem(LS_BOARD_SIZE) || "5"; // Default to 5
@ -1391,6 +1412,10 @@ function loadFromLocalStorage() {
saveCellStyleSettings();
refreshCellStyles();
});
clearSearch(); // Clear search highlights and input
clearMarks(false); // Clear visual marks
saveBoardState(); // Save the new randomized state (including cleared marks)
}
// --- Function to make all cells square and equal size ---