MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 582: Line 582:
     });
     });


function logCardsWithTypeAndSubject(typeValue, subjectValue) {
function filterCardsToShowOnlyTypeAndSubject(typeValue, subjectValue) {
// Initially hide all cards
$('div.filtered-list-item .card').hide();
$('.card').each(function() {
$('.card').each(function() {
// Extract the text within the anchor tag under the .type div
var typeText = $(this).find('.type a').text().trim();
var typeText = $(this).find('.type a').text().trim();
// Extract the text of the .subject div, which could have multiple values
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, log the card's title or any other required details
// If the conditions are met, show this card (and ensure its parent is visible)
var titleText = $(this).find('.title').text().trim();
$(this).closest('div.filtered-list-item').show();
console.log('Card with type "Book" and subject "Activism": ' + titleText);
}
}
});
});
}
}
// Call the function to log cards with the type "Book" and subject "Activism"
// Call the function to filter and display only cards with the type "Book" and subject "Activism"
logCardsWithTypeAndSubject('Book', 'Activism');
filterCardsToShowOnlyTypeAndSubject('Book', 'Activism');
});
});

Navigation menu