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 cards
// Initially hide all 'div.filtered-list-item' elements
$('div.filtered-list-item .card').hide();
$('div.filtered-list-item').hide();
$('.card').each(function() {
$('.card').each(function() {
Line 592: Line 592:
// 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
// Show this card and its parent 'div.filtered-list-item'
$(this).show().closest('div.filtered-list-item').show();
$(this).closest('div.filtered-list-item').show();
}
}
});
});
Line 600: Line 600:
// Call the function to filter and display only cards with the type "Book" and subject "Activism"
// Call the function to filter and display only cards with the type "Book" and subject "Activism"
filterCardsToShowOnlyTypeAndSubject('Book', 'Activism');
filterCardsToShowOnlyTypeAndSubject('Book', 'Activism');


});
});

Navigation menu