Misplaced Pages

User:Bradv/endlesscontribs.js: Difference between revisions

Article snapshot taken from[REDACTED] with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:Bradv Browse history interactively← Previous editContent deleted Content added
Revision as of 22:54, 20 December 2020 view sourceBradv (talk | contribs)Edit filter managers, Autopatrolled, Checkusers, Oversighters, Administrators37,875 edits leave bottom nav buttons up until you hit the button← Previous edit Latest revision as of 20:03, 27 May 2022 view source Enterprisey (talk | contribs)Edit filter managers, Autopatrolled, Administrators34,926 edits incredibly minor bugfix per User:Asartea 
Line 21: Line 21:
'class': 'mw-ui-button mw-ui-progressive'}) 'class': 'mw-ui-button mw-ui-progressive'})
.text('Load more') .text('Load more')
.insertAfter($('.mw-contributions-list')) .insertAfter($('.mw-pager-body'))
.click(function () { .click(function () {
$('body').addClass('endlesscontribs'); $('body').addClass('endlesscontribs');

Latest revision as of 20:03, 27 May 2022

(function( $, mw ) {
    'use strict';
    
    if (mw.config.get('wgCanonicalSpecialPageName')==='Contributions') {
        mw.loader.using("mediawiki.util").then(function () {
            const css = mw.util.addCSS(`
                body.endlesscontribs .mw-pager-navigation-bar:not(:first-of-type) {
                    display: none;
                }
                #endlesscontribs {
                    margin: 1em;
                }
            `)

            var nexturl = $('a').attr('href');
            if (nexturl) {
                var loading = false;

                const button = $('<span>', {
                    'id': 'endlesscontribs',
                    'class': 'mw-ui-button mw-ui-progressive'})
                .text('Load more')
                .insertAfter($('.mw-pager-body'))
                .click(function () {
                    $('body').addClass('endlesscontribs');
                    if (!loading) {
                        loading = true;
                        $.get(nexturl, function(data) {
                            var $html = $(data);
                            const $ul = $('.mw-contributions-list');
                            const $newul = $html.find('.mw-contributions-list > li');
                            $newul.each(function (index, element) {
                                $ul.append($(element));
                            })

                            nexturl = $html.find('a').attr('href');

                            if (!nexturl) {
                                button.remove();
                            }
                            loading = false;
                        })
                    }
                });                
            }
        });
    }
}(jQuery, mediaWiki ));
User:Bradv/endlesscontribs.js: Difference between revisions Add topic