mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-12-05 19:28:23 +00:00
89a9957cd4
Replace ??, ?., and replaceChildren() for better compatibility; hide pref panel in unsupported browsers * Update mixins.less * Update Sections.less * Update TableOfContents.less * Update interface-edit-section-links.less * Update mixins.less * Update Sections.less * Update TableOfContents.less * Update interface-edit-section-links.less * Update sections.js * Update tableOfContents.js * Update mwRestApi.js * Update mwRestApi.js * Update skins.citizen.preferences.js * Update mwActionApi.js * Update typeahead.js
53 lines
1.1 KiB
JavaScript
53 lines
1.1 KiB
JavaScript
const config = require( '../config.json' );
|
|
|
|
/**
|
|
* Build URL used for fetch request
|
|
*
|
|
* @param {string} input
|
|
* @return {string} url
|
|
*/
|
|
function getUrl( input ) {
|
|
const endpoint = config.wgScriptPath + '/rest.php/v1/search/title?q=',
|
|
query = '&limit=' + config.wgCitizenMaxSearchResults;
|
|
|
|
return endpoint + input + query;
|
|
}
|
|
|
|
/**
|
|
* Map raw response to Results object
|
|
*
|
|
* @param {Object} data
|
|
* @return {Object} Results
|
|
*/
|
|
function convertDataToResults( data ) {
|
|
const results = [];
|
|
|
|
data = ( data || [] ).pages || [];;
|
|
|
|
for ( let i = 0; i < data.length; i++ ) {
|
|
results[ i ] = {
|
|
id: data[ i ].id,
|
|
key: data[ i ].key,
|
|
title: data[ i ].title,
|
|
/* eslint-disable-next-line es-x/no-symbol-prototype-description */
|
|
desc: data[ i ].description
|
|
};
|
|
// Redirect title
|
|
// Since 1.38
|
|
if ( data[ i ].matched_title ) {
|
|
results[ i ].matchedTitle = data[ i ].matched_title;
|
|
}
|
|
|
|
if ( data[ i ].thumbnail && data[ i ].thumbnail.url ) {
|
|
results[ i ].thumbnail = data[ i ].thumbnail.url;
|
|
}
|
|
}
|
|
|
|
return results;
|
|
}
|
|
|
|
module.exports = {
|
|
getUrl: getUrl,
|
|
convertDataToResults: convertDataToResults
|
|
};
|