|
|
Line 581: |
Line 581: |
| window.location.href = '/Main_Page'; // Redirects to the home page | | window.location.href = '/Main_Page'; // Redirects to the home page |
| }); | | }); |
|
| |
| function filterCardsToShowOnlyTypeAndSubject(typeValue, subjectValue) {
| |
| // Initially hide all 'div.filtered-list-item' elements and their child cards
| |
| $('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() {
| |
| 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'
| |
| 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
| |
| $(this).closest('div.filtered-list-item').show();
| |
| $(this).show();
| |
| }
| |
| });
| |
| }
| |
|
| |
| // Call the function to filter and display only cards with the type "Book" and subject "Activism"
| |
| filterCardsToShowOnlyTypeAndSubject('Book', 'Activism');
| |
|
| |
| }); | | }); |