MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Tag: Manual revert
No edit summary
Tag: Reverted
Line 583: Line 583:


function filterCardsToShowOnlyTypeAndSubject(typeValue, subjectValue) {
function filterCardsToShowOnlyTypeAndSubject(typeValue, subjectValue) {
// Initially hide all 'div.filtered-list-item' elements and their child cards
// Initially hide all 'div.filtered-list-item' elements
$('div.filtered-list-item').each(function() {
$('div.filtered-list-item').hide();
$(this).hide(); // Hides the parent
$(this).find('.card').hide(); // Ensures the child cards are also hidden
});
// Iterate over each card to apply the filter
// Define a common function to handle the filtering logic
$('.card').each(function() {
function handleFiltering(cardSelector) {
var typeText = $(this).find('.type a').text().trim();
$(cardSelector).each(function() {
var subjectText = $(this).find('.subject').text().trim();
var typeText = $(this).find('.type a').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)) {
// Show this card's parent 'div.filtered-list-item' and the card itself
// Show this card's parent 'div.filtered-list-item'
$(this).closest('div.filtered-list-item').show();
$(this).closest('div.filtered-list-item').show();
$(this).show();
}
}
});
});
}
// Apply the filter to both '.card' and '.list-card'
handleFiltering('.card');
handleFiltering('.list-card');
}
}
// Call the function to filter and display only cards with the type "Book" and subject "Activism"
// Call the function to filter and display only the appropriate cards
filterCardsToShowOnlyTypeAndSubject('Book', 'Activism');
filterCardsToShowOnlyTypeAndSubject('Book', 'Activism');
});
});

Navigation menu