MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Tag: Manual revert
No edit summary
Line 8: Line 8:
     $('.head-box').click(function() {
     $('.head-box').click(function() {
         window.location.href = '/Main_Page'; // Redirects to the home page
         window.location.href = '/Main_Page'; // Redirects to the home page
    });
    // Loop through each card to format related articles
    cards.each(function() {
        // Check if the card has related articles
        var relatedArticles = $(this).find('.related-articles');
        if (relatedArticles.length > 0) {
            // Get all the related article elements
            var relatedArticleElements = relatedArticles.find('.related-article');
            // Create an array to store unique related articles
            var uniqueArticles = [];
            // Loop through each related article element
            relatedArticleElements.each(function() {
                // Remove <p> tags from the article
                $(this).find('p').remove();
                // Convert the article HTML to a string
                var articleHTML = $(this)[0].outerHTML;
                // Check if the article HTML already exists in the uniqueArticles array
                if ($.inArray(articleHTML, uniqueArticles) === -1) {
                    // If it doesn't exist, add it to the uniqueArticles array
                    uniqueArticles.push(articleHTML);
                }
            });
            // Clear the content of the related articles container
            relatedArticles.empty();
            // Append the unique related articles back to the container
            relatedArticles.append(uniqueArticles.join(''));
        }
     });
     });


Navigation menu