4,090
edits
No edit summary Tags: Manual revert Reverted |
No edit summary Tag: Manual revert |
||
Line 583: | Line 583: | ||
function filterCardsToShowOnlyTypeAndSubject(typeValue, subjectValue) { | function filterCardsToShowOnlyTypeAndSubject(typeValue, subjectValue) { | ||
// Initially hide all 'div.filtered-list-item' elements | // Initially hide all 'div.filtered-list-item' elements | ||
$('div.filtered-list-item' | $('div.filtered-list-item').hide(); | ||
// | // Combine the selectors for '.card' and '.list-card' elements | ||
$('.card').each(function() { | $('.card, .list-card').each(function() { | ||
var typeText = $(this).find('.type a').text().trim(); | var typeText = $(this).find('.type a').text().trim(); | ||
var subjectText = $(this).find('.subject').text().trim(); | var subjectText = $(this).find('.subject').text().trim(); | ||
// Check if the | // Check if the element's type matches 'Book' and if the subject includes 'Activism' | ||
if (typeText === typeValue && subjectText.split(',').map(function(s) { return s.trim(); }).includes(subjectValue)) { | if (typeText === typeValue && subjectText.split(',').map(function(s) { return s.trim(); }).includes(subjectValue)) { | ||
// Show this | // Show this element's parent 'div.filtered-list-item' | ||
$(this).closest('div.filtered-list-item').show(); | $(this).closest('div.filtered-list-item').show(); | ||
} | } | ||
}); | }); | ||
} | } | ||
// Call the function to filter and display only cards | // Call the function to filter and display only the appropriate cards | ||
filterCardsToShowOnlyTypeAndSubject('Book', 'Activism'); | filterCardsToShowOnlyTypeAndSubject('Book', 'Activism'); | ||
}); | }); |