Page MenuHomeWickedGov Phorge

ext.inputBox.js
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

ext.inputBox.js

( function () {
mw.hook( 'wikipage.content' ).add( () => {
const inputBoxForms = document.querySelectorAll( '.inputbox-searchengine-not-set' );
// Replace form action with the user's preference.
const userPref = mw.user.options.get( 'search-special-page' );
const searchPages = mw.config.get( 'SpecialSearchPages' );
if ( searchPages[ userPref ] !== undefined ) {
const searchUrl = mw.util.getUrl( searchPages[ userPref ] );
for ( const inputboxForm of inputBoxForms ) {
inputboxForm.action = searchUrl;
}
}
// Change the 'search' parameter on submit, if searchfilter is present.
// This avoids an HTTP redirect that happens as a no-JS fallback.
for ( const inputboxForm of inputBoxForms ) {
const searchFilter = inputboxForm.querySelector( 'input[name="searchfilter"]' );
if ( searchFilter ) {
inputboxForm.addEventListener( 'submit', () => {
const search = inputboxForm.querySelector( 'input[name="search"]' );
if ( search ) {
// This matches what's done in InputBoxHooks::onSpecialPageBeforeExecute().
search.value = search.value.trim() + ' ' + searchFilter.value.trim();
// Remove the searchfilter input, so it doesn't trigger the redirect.
searchFilter.remove();
}
} );
}
}
} );
}() );

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 22, 19:36 (1 d, 11 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
e4/de/1ae95ede792ba709eeff4c3d5e29
Default Alt Text
ext.inputBox.js (1 KB)

Event Timeline