MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 5: Line 5:
     var showArticleWrapper = $('#show-article-wrapper');
     var showArticleWrapper = $('#show-article-wrapper');


function formatParagraphs(text) {
        // Split the text into paragraphs and wrap each in a <span>
        var paragraphs = text.split('\n').filter(function (p) { return p.trim() !== '' });
        return paragraphs.map(function (p) { return '<span>' + p.trim() + '</span>'; }).join('');
    }
       
    // Description formatting for Community Cards
    function formatCommunityCardDescriptions() {
        console.log("Formatting community card descriptions");
        $('.community-card').each(function() {
            console.log("Processing a community card");
            var descriptionContainer = $(this).find('.community-description');
            var rawDescription = descriptionContainer.text();
            console.log("Raw Description:", rawDescription);
            var formattedDescription = formatParagraphs(rawDescription);
            descriptionContainer.html(formattedDescription);
            console.log("Formatted Description HTML:", descriptionContainer.html());
        });
    }
    // Check if we are on a page that requires community card formatting
    if ($('.community-card').length) {
        formatCommunityCardDescriptions();
    }
   
     // Delegate the mousedown event to the '.card' elements inside the '#list' container
     // Delegate the mousedown event to the '.card' elements inside the '#list' container
     $('#list').on('mousedown', '.card', function (event) {
     $('#list').on('mousedown', '.card', function (event) {
Line 103: Line 128:
         }
         }


        function formatParagraphs(text) {
            // Split the text into paragraphs and wrap each in a <span>
            var paragraphs = text.split('\n').filter(function (p) { return p.trim() !== '' });
            return paragraphs.map(function (p) { return '<span>' + p.trim() + '</span>'; }).join('');
        }
       
        // Description formatting for Community Cards
    function formatCommunityCardDescriptions() {
        console.log("Formatting community card descriptions");
        $('.community-card').each(function() {
            console.log("Processing a community card");
            var descriptionContainer = $(this).find('.community-description');
            var rawDescription = descriptionContainer.text();
            console.log("Raw Description:", rawDescription);
            var formattedDescription = formatParagraphs(rawDescription);
            descriptionContainer.html(formattedDescription);
            console.log("Formatted Description HTML:", descriptionContainer.html());
        });
    }
    // Check if we are on a page that requires community card formatting
    if ($('.community-card').length) {
        formatCommunityCardDescriptions();
    }
       
         function formatSimpleDate(inputDate) {
         function formatSimpleDate(inputDate) {
             // Remove spaces from the date string
             // Remove spaces from the date string

Navigation menu