mediawiki-skins-Citizen/resources/skins.citizen.search/searchClient.js
github-actions 96171236d7 ci: 👷 lint code to MediaWiki standards
Check commit and GitHub actions for more details
2024-01-27 02:51:04 +00:00

23 lines
609 B
JavaScript

const searchClientsData = require( './searchClients/searchClients.json' );
function searchClient( config ) {
return {
active: null,
getData: function ( key, value ) {
const data = Object.values( searchClientsData ).find( ( item ) => item[ key ] === value );
return data;
},
setActive: function ( id ) {
const data = this.getData( 'id', id );
if ( data && data !== this.active ) {
const client = require( `./searchClients/${ data.id }.js` );
this.active = data;
this.active.client = client( config );
}
}
};
}
/** @module searchClient */
module.exports = searchClient;