MediaWiki:Common.js: Difference between revisions

From Hidden Mickey Wiki

No edit summary
No edit summary
Line 35: Line 35:
// Add Edit Source to user dropdown
// Add Edit Source to user dropdown
mw.loader.using('mediawiki.util', function () {
mw.loader.using('mediawiki.util', function () {
     // Add a new entry into the user dropdown
     // Edit Source
     mw.util.addPortletLink(
     mw.util.addPortletLink(
         'p-personal',                        // user menu ID
         'p-personal',                        // user menu ID
         mw.util.getUrl( mw.config.get('wgPageName'), { action: 'edit' } ),  
         mw.util.getUrl( mw.config.get('wgPageName'), { action: 'edit' } ),  
         'Edit Source',
         'Edit Source',
        'pt-editsource'
    );
    // View History
    mw.util.addPortletLink(
        'p-personal',                        // user menu ID
        mw.util.getUrl( mw.config.get('wgPageName'), { action: 'history' } ),
        'View History',
         'pt-editsource'
         'pt-editsource'
     );
     );
});
});

Revision as of 00:09, 20 September 2025

/* Any JavaScript here will be loaded for all users on every page load. */
// JavaScript code to save checkbox state and restore it when the page loads
$(document).ready(function() {
    // Function to save the state of checkboxes to localStorage
    function saveCheckboxState() {
        $('input[type="checkbox"]').each(function() {
            localStorage.setItem($(this).attr('id'), $(this).prop('checked'));
        });
    }

    // Function to load the state of checkboxes from localStorage
    function loadCheckboxState() {
        $('input[type="checkbox"]').each(function() {
            const savedState = localStorage.getItem($(this).attr('id'));
            if (savedState !== null) {
                $(this).prop('checked', savedState === 'true');
            }
        });
    }

    // Load the saved checkbox state when the page is loaded
    loadCheckboxState();

    // Save the checkbox state whenever a checkbox is changed
    $('input[type="checkbox"]').change(function() {
        saveCheckboxState();
    });
});

// Adjust the search box width
$(document).ready(function () {
    $('#searchInput').css('width', '600px'); // Adjust width as needed
});

// Add Edit Source to user dropdown
mw.loader.using('mediawiki.util', function () {
    // Edit Source
    mw.util.addPortletLink(
        'p-personal',                        // user menu ID
        mw.util.getUrl( mw.config.get('wgPageName'), { action: 'edit' } ), 
        'Edit Source',
        'pt-editsource'
    );
    // View History
    mw.util.addPortletLink(
        'p-personal',                        // user menu ID
        mw.util.getUrl( mw.config.get('wgPageName'), { action: 'history' } ), 
        'View History',
        'pt-editsource'
    );
});