Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Common.js: Difference between revisions

MediaWiki interface page
(Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: // Sort categories alphabetically by the first character after the colon $(function() { var $categories = $('.mw-normal-catlinks ul li'); $categories.sort(function(a, b) { var textA = $(a).text().toUpperCase(); var textB = $(b).text().toUpperCase(); var charA = textA.match(/:(.)/)[1]; var charB = textB.match(/:(.)/)[1]; return (charA < charB) ? -1 :...")
 
No edit summary
Tag: Reverted
Line 2: Line 2:


// Sort categories alphabetically by the first character after the colon
// Sort categories alphabetically by the first character after the colon
$(function() {
<style>
    var $categories = $('.mw-normal-catlinks ul li');
/* Category sorting */
     $categories.sort(function(a, b) {
.mw-normal-catlinks ul {
        var textA = $(a).text().toUpperCase();
     columns: 2; /* Adjust the number of columns as needed */
        var textB = $(b).text().toUpperCase();
    -webkit-columns: 2;
        var charA = textA.match(/:(.)/)[1];
    -moz-columns: 2;
        var charB = textB.match(/:(.)/)[1];
}
        return (charA < charB) ? -1 : (charA > charB) ? 1 : 0;
 
    });
.mw-normal-catlinks ul li {
    $('.mw-normal-catlinks ul').empty().append($categories);
    display: inline-block;
});
    width: 100%;
    box-sizing: border-box;
}
</style>

Revision as of 20:42, 17 March 2024

/* Any JavaScript here will be loaded for all users on every page load. */

// Sort categories alphabetically by the first character after the colon
<style>
/* Category sorting */
.mw-normal-catlinks ul {
    columns: 2; /* Adjust the number of columns as needed */
    -webkit-columns: 2;
    -moz-columns: 2;
}

.mw-normal-catlinks ul li {
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
}
</style>