MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
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 and their child cards
$('div.filtered-list-item').hide();
$('div.filtered-list-item').each(function() {
$(this).hide(); // Hides the parent
$(this).find('.card').hide(); // Ensures the child cards are also hidden
});
// Iterate over each card to apply the filter
$('.card').each(function() {
$('.card').each(function() {
var typeText = $(this).find('.type a').text().trim();
var typeText = $(this).find('.type a').text().trim();
Line 592: Line 596:
// 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)) {
// Show this card and its parent 'div.filtered-list-item'
// Show this card's parent 'div.filtered-list-item' and the card itself
$(this).closest('div.filtered-list-item').show();
$(this).closest('div.filtered-list-item').show();
$(this).show();
}
}
});
});
Line 601: Line 606:
filterCardsToShowOnlyTypeAndSubject('Book', 'Activism');
filterCardsToShowOnlyTypeAndSubject('Book', 'Activism');
});
});

Navigation menu