MediaWiki:Common.js: Difference between revisions

No edit summary
No edit summary
 
(27 intermediate revisions by the same user not shown)
Line 229: Line 229:




/*$( function(){
$( function(){
var countPoem2 = $(".Poem2-Ekatra");
var countPoem2 = $(".Poem2-Ekatra");
Line 264: Line 264:
});
});
}
}
}); */
$( function(){
    var countPoem2 = $(".Poem2-Ekatra");
    if( countPoem2.length > 0 ){
        var Poem2lenghtArray = [];
        for (var k = 0; k <= countPoem2.length; k++) {
            Poem2lenghtArray.push(k);
        }
        Poem2lenghtArray.forEach(function(j) {
            var poemElement = $(".Poem2-Ekatra").eq(j);
            if( poemElement.length ){
                var poemText = poemElement.html();
                var poemArray = poemText.split("\n");
                poemElement.text("");
                // First measure
                poemArray.forEach(function(i) {
                    i = $.trim(i);
                    // Skip blank lines
                    if (i === '') {
                        return;
                    }
                    poemElement.append(
                        '<p style="text-indent: 2em;">' + i + '</p>'
                    );
                });
                // Second measure
                poemElement.children('p').each(function () {
                    $(this).css('text-indent', '2em');
                });
            }
        });
    }


});
});
Line 1,238: Line 1,186:


});
});
/*-----------------------------------------28-05-2026--------------------------------/
/*-----------------------------------------28-05-2026--------------------------------*/


/*--------------------------------------swati---------------------------------------*/
/*--------------------------------------swati---------------------------------------*/
/* hide sub suggestion in global searchbox */
/* hide sub suggestion in global searchbox */
$(function () {
/*$(function () {


     function removeSubpageResults() {
     function removeSubpageResults() {
Line 1,284: Line 1,232:


});
});
 
*/
/* hide sub suggestion in search page */
/* hide sub suggestion in search page */
$(document).ready(function () {
/*$(document).ready(function () {


     // Inject CSS instantly
     // Inject CSS instantly
Line 1,329: Line 1,277:


});
});
 
*/
$(document).ready(function () {
/*$(document).ready(function () {


     // Override broken REST API search
     // Override broken REST API search
Line 1,362: Line 1,310:


});
});
 
*/
/*
$(function () {
$(function () {


Line 1,391: Line 1,340:


});
});
 
*/
/*--------------------------------------chirag---------------------------------------*/
/*--------------------------------------chirag---------------------------------------*/
$(function () {
$(function () {
Line 1,436: Line 1,385:
         title.insertAfter(booksHeading);
         title.insertAfter(booksHeading);
     }
     }
});
/*---------------------------22-06-2026---------------------------------------*/
$(function () {
    $('.ekatra-right-author').each(function () {
        // Remove blank <p> inside Poem2 after author
        $(this).nextAll('p').each(function () {
            var html = $.trim($(this).html());
            if (html === '' || html === '<br>' || html === '<br/>' || html === '<br />') {
                $(this).remove();
            } else {
                return false;
            }
        });
        // Remove blank <p><br></p> after Poem2 block
        var p = $(this).closest('.Poem2-Ekatra').next('p');
        if (p.length && p.find('br').length) {
            p.remove();
        }
    });
});
/*-----------------------------------------01-07-2026-------------------------------------------*/
/* Keep WikiEditor toolbar sticky below the Ekatra toolbar */
$(function () {
    function stickyToolbar() {
        var $toolbar = $('.wikiEditor-ui-top');
        if (!$toolbar.length) {
            return;
        }
        $toolbar.css({
            position: 'sticky',
            top: $('#editpage-specialchars').outerHeight() + 'px',
            zIndex: 999,
            background: '#fff'
        });
        clearInterval(timer);
    }
    var timer = setInterval(stickyToolbar, 100);
    $(window).on('resize', stickyToolbar);
});
/*----------------------------------08-07-2026----------------------------------*/
/* Remove blank <p><br></p> after Author template without removing TemplateStyles */
$(function () {
    $('.ekatra-author').next('p').each(function () {
        var $p = $(this);
        // Move TemplateStyles outside the paragraph
        $p.children('style[data-mw-deduplicate]').each(function () {
            $(this).insertBefore($p);
        });
        // Remove only <br>
        $p.children('br').remove();
        // Remove the paragraph only if it is now empty
        if (
            $.trim($p.text()) === '' &&
            $p.children().length === 0
        ) {
            $p.remove();
        }
    });


});
});