User:Enterprisey/search-shortcuts.js

//

$( document ).ready( function() {

var expansions = {

"wp:rfa": "WP:Requests for adminship",

"wp:afd": "WP:Articles for deletion",

"wp:brfa": "WP:Bots/Requests for approval",

"wp:tfd": "WP:Templates for discussion/Log",

't:': 'Template:',

'c:': 'Category:',

'p:': 'Portal:',

'h:': 'Help:',

'd:': 'Draft:',

'wp:cci': 'WP:Contributor copyright investigations',

'wp:spi': 'WP:Sockpuppet investigations',

};

$( "#searchInput" ).on( "keydown", function( event ) {

if( event.key === "/" ) {

var val = $( this ).val().toLowerCase();

var expansion;

if( expansion = expansions[val] ) {

$( this ).val( expansion );

}

} else if( $( this ).val().trim().indexOf( "{{" ) === 0 ) {

$( this ).val( $( this ).val().replace( "{{", "Template:" ).replace( "}}", "" ) );

}

} );

} );

//