MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 586: Line 586:
$('div.filtered-list-item').hide();
$('div.filtered-list-item').hide();
// Define a common function to handle the filtering logic
// Combine the selectors for '.card' and '.list-card' elements
function handleFiltering(cardSelector) {
$('.card, .list-card').each(function() {
$(cardSelector).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 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 card's parent 'div.filtered-list-item'
// Show this element's parent 'div.filtered-list-item'
$(this).closest('div.filtered-list-item').show();
$(this).closest('div.filtered-list-item').show();
}
}
});
});
}
// Apply the filter to both '.card' and '.list-card'
handleFiltering('.card');
handleFiltering('.list-card');
}
}
// Call the function to filter and display only the appropriate cards
// Call the function to filter and display only the appropriate cards
filterCardsToShowOnlyTypeAndSubject('Book', 'Activism');
filterCardsToShowOnlyTypeAndSubject('Book', 'Activism');
});
});

Navigation menu