MediaWiki:Common.js
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.
/* Soulscribe — auto-generated, do not edit manually */
/* ── Auto-pin the main navigation menu to the left sidebar on desktop ── */
( function () {
if ( window.innerWidth < 1000 ) { return; }
var pinBtn = document.querySelector(
'.vector-pinnable-header-pin-button[data-event-name="pinnable-header.vector-main-menu.pin"]'
);
if ( pinBtn ) { pinBtn.click(); }
}() );
/* ── Relationship table live filter ────────────────────────────────── */
/* Filters rows in any .wb-relationship-table as the user types. */
( function () {
function initFilters() {
document.querySelectorAll( '.wb-rel-filter' ).forEach( function ( input ) {
var wrap = input.closest( '.wb-rel-filter-wrap' );
if ( !wrap ) { return; }
var table = wrap.nextElementSibling;
// step past any whitespace text nodes to find the table
while ( table && table.nodeType !== 1 ) { table = table.nextSibling; }
if ( !table || table.tagName !== 'TABLE' ) { return; }
input.addEventListener( 'input', function () {
var q = input.value.toLowerCase().trim();
var rows = table.querySelectorAll( 'tbody tr' );
rows.forEach( function ( row ) {
var text = row.textContent.toLowerCase();
row.style.display = ( !q || text.indexOf( q ) !== -1 ) ? '' : 'none';
} );
} );
} );
}
if ( document.readyState === 'loading' ) {
document.addEventListener( 'DOMContentLoaded', initFilters );
} else {
initFilters();
}
}() );