Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// <nowiki>
//Used to demonstrate that morebits is loaded, even when Twinkle is not enabled.
//https://en.wikipedia.org/wiki/Wikipedia:Morebits
//The idea was to use morebits to put the {{duplicated citations}} template in the correct place according to [[MOS:ORDER]]
//This doesn't really do anything at the moment.

mw.loader.using(['ext.gadget.morebits'], function() {
    // Only run on view pages, not on edit pages or other special pages
    if (mw.config.get('wgAction') !== 'view') return;

    // Function to demonstrate Morebits status messages
    function demonstrateMorebitsStatus() {
        // Initialize Morebits status system
        Morebits.status.init(document.getElementById('mw-content-text'));

        // Create a new overall status
        var overallStatus = new Morebits.status('Morebits Status Demo');

        // Show an info message
        overallStatus.info('Starting', 'Beginning the demonstration');

        // Simulate some work and show different status types
        setTimeout(function() {
            var status1 = new Morebits.status('Step 1');
            status1.info('Processing', 'Doing some work...');

            setTimeout(function() {
                status1.success('Complete', 'Step 1 finished successfully');

                var status2 = new Morebits.status('Step 2');
                status2.warn('Caution', 'This step might have issues');

                setTimeout(function() {
                    status2.error('Failed', 'Step 2 encountered an error');

                    var status3 = new Morebits.status('Step 3');
                    status3.status('In Progress', 'Final step...');

                    setTimeout(function() {
                        status3.info('Done', 'Step 3 completed');
                        overallStatus.success('Complete', 'All steps finished');
                    }, 2000);
                }, 2000);
            }, 2000);
        }, 2000);
    }

    // Add a button to trigger the demonstration
    $(function() {
        var $button = $('<button>')
            .text('Demonstrate Morebits Status')
            .click(demonstrateMorebitsStatus);
        
        $('#mw-content-text').prepend($button);
    });
});

// </nowiki>