b l o g g i n  s p a c e wiki

MediaWiki:Common.js

From bloggin space wiki
Revision as of 23:31, 13 January 2026 by Grug (talk | contribs)
Jump to navigation Jump to search

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.
/* Any JavaScript here will be loaded for all users on every page load. */
$(function() {
    $('#p-search').clone().appendTo('#mw-panel .portal:first');
});

// Custom sitenotice search bar - Vector legacy - places search BELOW existing notice text
( function () {
    'use strict';

    mw.hook( 'wikipage.content' ).add( function ( $content ) {
        // Don't add twice
        if ( document.querySelector( '.sitenotice-search' ) ) return;

        var $siteNotice = $( '#siteNotice' );

        // If #siteNotice is missing (rare), create it
        if ( $siteNotice.length === 0 ) {
            $siteNotice = $( '<div id="siteNotice"></div>' );
            $( '#mw-content-text' ).before( $siteNotice );
            console.log( 'Created new #siteNotice' );
        }

        var searchHtml = 
            '<div class="sitenotice-search" style="margin: 1.2em auto 0.6em; max-width: 500px; text-align: center;">' +
                '<form action="' + mw.config.get('wgScript') + '?title=Special:Search" method="get">' +
                    '<input type="search" name="search" placeholder="search here, bub..." ' +
                           'class="sitenotice-search-input" style="width: 80%; max-width: 500px; height: 2.4em; ' +
                           'padding: 0 0.8em; font-size: 1.1em; border: 1px solid #FF69B4; border-radius: 0px;" />' +
                    // '<input type="submit" value="Go" style="height: 2.4em; margin-left: -1px; border-radius: 0 3px 3px 0;">' +
                '</form>' +
            '</div>';

        $siteNotice.append( searchHtml );  // ← Changed from .prepend() to .append()
        console.log( 'Sitenotice search bar added BELOW existing content' );
    } );
}() );