4,554
edits
No edit summary |
No edit summary |
||
Line 582: | Line 582: | ||
}); | }); | ||
function | function filterCardsToShowOnlyTypeAndSubject(typeValue, subjectValue) { | ||
// Initially hide all cards | |||
$('div.filtered-list-item .card').hide(); | |||
$('.card').each(function() { | $('.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 card's type matches 'Book' and if the subject includes 'Activism' | // Check if the card'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)) { | ||
// If the conditions are met, | // If the conditions are met, show this card (and ensure its parent is visible) | ||
$(this).closest('div.filtered-list-item').show(); | |||
} | } | ||
}); | }); | ||
} | } | ||
// Call the function to | // Call the function to filter and display only cards with the type "Book" and subject "Activism" | ||
filterCardsToShowOnlyTypeAndSubject('Book', 'Activism'); | |||
}); | }); |