Toggle menu
9
0
4
180
sampsphere.com
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Common.js

MediaWiki interface page

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
$(document).ready(function() {
    // Wait for the document to be fully loaded before making changes
    setTimeout(function() {
        // Assuming the last modified text is inside an element with class 'lastmodified'
        var lastModifiedElement = $('.lastmodified');
        
        if (lastModifiedElement.length > 0) { // Check if the element exists
            // Get the current date and format it nicely
            var lastModified = new Date(document.lastModified);
            var formattedDate = lastModified.toLocaleDateString() + " " + lastModified.toLocaleTimeString();
            
            // Update the text content
            lastModifiedElement.text("Last Modified: " + formattedDate);
            
            // Apply styles for better readability
            lastModifiedElement.css({
                'background-color': '#f0f0f0', // Light grey background
                'color': '#333', // Dark grey text for contrast
                'padding': '5px',
                'border-radius': '3px',
                'font-family': 'Arial, sans-serif',
                'font-size': '12px'
            });
        } else {
            // If no specific element found, maybe append to sidebar or create one
            var sidebar = $('#mw-panel');
            if (sidebar.length > 0) {
                var newElement = $('<div class="lastmodified">Last Modified: ' + formattedDate + '</div>');
                newElement.css({
                    'background-color': '#f0f0f0',
                    'color': '#333',
                    'padding': '5px',
                    'margin': '5px 0',
                    'border-radius': '3px',
                    'font-family': 'Arial, sans-serif',
                    'font-size': '12px'
                });
                sidebar.prepend(newElement);
            }
        }
    }, 500); // Small delay to ensure sidebar is fully loaded
});