This commit is contained in:
Joey Yakimowich-Payne 2025-04-17 21:49:04 -06:00
commit eb0a5aab05
No known key found for this signature in database
GPG key ID: 6BFE655FA5ABD1E1
3 changed files with 44 additions and 0 deletions

View file

@ -1101,6 +1101,35 @@ function loadFromLocalStorage() {
applyBoardBgStyle();
});
// --- Search Listener ---
const searchInput = document.getElementById('search-input');
if (searchInput) {
searchInput.addEventListener('input', () => {
const searchTerm = searchInput.value.trim().toLowerCase();
const cells = document.querySelectorAll('#bingo-board .bingo-cell');
// Split search term into words
const searchWords = searchTerm.split(/\s+/).filter(word => word.length > 0);
cells.forEach(cell => {
const textSpan = cell.querySelector('.bingo-cell-text');
let isMatch = false;
if (textSpan && searchWords.length > 0) {
const cellText = textSpan.textContent.trim().toLowerCase();
// Check if ALL search words are included in the cell text
isMatch = searchWords.every(word => cellText.includes(word));
}
// Add or remove highlight based on match status
if (isMatch) {
cell.classList.add('highlighted');
} else {
cell.classList.remove('highlighted');
}
});
});
}
// --- Other Listeners ---
window.addEventListener('resize', equalizeCellSizes);
equalizeCellSizes(); // Initial call after load