MediaWiki:Common.js: Difference between revisions

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


     function filterCards(entityValue, typeValue) {
     function logCardsWithSameClasses() {
        var cardsInfo = {}; // Object to store the occurrence of entity-type combinations
   
         $('.card').each(function() {
         $('.card').each(function() {
            // Using jQuery to find the entity and type within the current card
             var entityText = $(this).find('.entity').text().trim();
             var entityText = $(this).find('.entity').text().trim();
             var typeText = $(this).find('.type').text().trim();
             var typeText = $(this).find('.type').text().trim();
            var key = entityText + '-' + typeText; // Creating a unique key for the combination
      
      
             // Logging the values to the console for debugging, using string concatenation
             if (!cardsInfo[key]) {
             console.log('Card entity: ' + entityText + ', Card type: ' + typeText);
                cardsInfo[key] = []; // Initialize an array if this is the first encounter
             }
      
      
             // Check if the card matches both the entity and type filters
             cardsInfo[key].push(this); // Add the card to the array for this entity-type combination
             if (entityText === entityValue && typeText === typeValue) {
        });
                 $(this).show(); // Show the card if it matches
   
            } else {
        // Iterate over the stored information to log out the cards with the same classes
                 $(this).hide(); // Hide the card if it doesn't match
        $.each(cardsInfo, function(key, cards) {
             if (cards.length > 1) { // More than one card with the same entity-type combination
                 console.log('Cards with entity-type ' + key + ':');
                 $.each(cards, function(index, card) {
                    console.log(card); // Log the card element, or you can log an identifier or other info
                });
             }
             }
         });
         });
     }
     }
      
      
     // Example usage: filter cards by 'Collective' entity and 'Image' type
     // Call the function to log out the cards with the same classes
     filterCards('Collective', 'Image');  
     logCardsWithSameClasses();
   
      
      
});
});

Navigation menu