wiki.techinc.nl/resources/src/mediawiki.userSuggest.js
Fomafix 213d45e5dd Make first char of username in ApiQueryAllUsers case-insensitive
This change uses $contentLanguage->ucfirst( $name ) to get the
canonical username like this is done in UserNameUtils::getCanonical().
This makes the first character case-insensitive. The toUpperCase() in
JavaScript is not needed anymore.

toUpperCase() in JavaScript and $contentLanguage->ucfirst() in PHP
differ on some characters:
* JavaScript: "ß".toUpperCase() // "SS"
* PHP: $contentLanguage->ucfirst( "ß" ) // "ß"

Bug: T291339
Change-Id: Id9afb2dd0212e4b871bb6a7a9d8762e1bcb81d6a
2021-09-21 06:21:21 +00:00

40 lines
816 B
JavaScript

/*!
* Add autocomplete suggestions for names of registered users.
*/
( function () {
var api, config;
config = {
fetch: function ( userInput, response, maxRows ) {
var node = this[ 0 ];
api = api || new mw.Api();
$.data( node, 'request', api.get( {
formatversion: 2,
action: 'query',
list: 'allusers',
auprefix: userInput,
aulimit: maxRows
} ).done( function ( data ) {
var users = data.query.allusers.map( function ( userObj ) {
return userObj.name;
} );
response( users );
} ) );
},
cancel: function () {
var node = this[ 0 ],
request = $.data( node, 'request' );
if ( request ) {
request.abort();
$.removeData( node, 'request' );
}
}
};
$( function () {
$( '.mw-autocomplete-user' ).suggestions( config );
} );
}() );