mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-24 06:24:22 +00:00
refactor(core): ♻️ clean up various eslint errors
This commit is contained in:
parent
608a2be932
commit
4ef5376cab
|
@ -105,10 +105,9 @@ function getPref() {
|
|||
/**
|
||||
* Save to localstorage if preference is changed
|
||||
*
|
||||
* @param {Event} event
|
||||
* @return {void}
|
||||
*/
|
||||
function setPref( event ) {
|
||||
function setPref() {
|
||||
const
|
||||
// eslint-disable-next-line compat/compat
|
||||
formData = Object.fromEntries( new FormData( document.getElementById( CLASS + '-form' ) ) ),
|
||||
|
@ -367,7 +366,7 @@ function initPref( window ) {
|
|||
// MIT. Copyright (c) Feross Aboukhadijeh.
|
||||
if ( typeof Object.fromEntries !== 'function' ) {
|
||||
Object.defineProperty( Object, 'fromEntries', {
|
||||
value( iterable ) {
|
||||
value( iterable ) {
|
||||
return Array.from( iterable ).reduce( ( obj, [ key, val ] ) => {
|
||||
obj[ key ] = val;
|
||||
return obj;
|
||||
|
|
|
@ -15,11 +15,14 @@ function getUrl( input ) {
|
|||
|
||||
if ( input.includes( ':' ) ) {
|
||||
let namespace = input.split( ':' )[ 0 ];
|
||||
if ( namespace === 'Category' ) { namespace = ':' + namespace; }
|
||||
if ( namespace === 'Category' ) {
|
||||
namespace = ':' + namespace;
|
||||
}
|
||||
input = input.split( ':' )[ 1 ];
|
||||
askQuery += '[[' + namespace + ':+]]';
|
||||
}
|
||||
|
||||
/* eslint-disable-next-line es-x/no-string-prototype-replaceall */
|
||||
askQuery += askQueryTemplate.replaceAll( '${input}', input );
|
||||
askQuery += '|limit=' + maxResults;
|
||||
|
||||
|
@ -52,11 +55,19 @@ function convertDataToResults( data ) {
|
|||
let textEN = '';
|
||||
let textResult = '';
|
||||
for ( const text of item.printouts.displaytitle ) {
|
||||
if ( text[ 'Language code' ].item[ 0 ] === userLang ) { textResult = text.Text.item[ 0 ]; }
|
||||
if ( text[ 'Language code' ].item[ 0 ] === 'en' ) { textEN = text.Text.item[ 0 ]; }
|
||||
if ( text[ 'Language code' ].item[ 0 ] === userLang ) {
|
||||
textResult = text.Text.item[ 0 ];
|
||||
}
|
||||
if ( text[ 'Language code' ].item[ 0 ] === 'en' ) {
|
||||
textEN = text.Text.item[ 0 ];
|
||||
}
|
||||
}
|
||||
if ( textResult === '' ) {
|
||||
textResult = textEN;
|
||||
}
|
||||
if ( textResult === '' ) {
|
||||
textResult = item.printouts.displaytitle[ 0 ].Text.item[ 0 ];
|
||||
}
|
||||
if ( textResult === '' ) { textResult = textEN; }
|
||||
if ( textResult === '' ) { textResult = item.printouts.displaytitle[ 0 ].Text.item[ 0 ]; }
|
||||
return textResult;
|
||||
} else if ( item.printouts.displaytitle && item.printouts.displaytitle.length ) {
|
||||
return item.printouts.displaytitle[ 0 ];
|
||||
|
@ -72,11 +83,19 @@ function convertDataToResults( data ) {
|
|||
let textEN = '';
|
||||
let textResult = '';
|
||||
for ( const text of item.printouts.desc ) {
|
||||
if ( text[ 'Language code' ].item[ 0 ] === userLang ) { textResult = text.Text.item[ 0 ]; }
|
||||
if ( text[ 'Language code' ].item[ 0 ] === 'en' ) { textEN = text.Text.item[ 0 ]; }
|
||||
if ( text[ 'Language code' ].item[ 0 ] === userLang ) {
|
||||
textResult = text.Text.item[ 0 ];
|
||||
}
|
||||
if ( text[ 'Language code' ].item[ 0 ] === 'en' ) {
|
||||
textEN = text.Text.item[ 0 ];
|
||||
}
|
||||
}
|
||||
if ( textResult === '' ) {
|
||||
textResult = textEN;
|
||||
}
|
||||
if ( textResult === '' ) {
|
||||
textResult = item.printouts.desc[ 0 ].Text.item[ 0 ];
|
||||
}
|
||||
if ( textResult === '' ) { textResult = textEN; }
|
||||
if ( textResult === '' ) { textResult = item.printouts.desc[ 0 ].Text.item[ 0 ]; }
|
||||
return textResult;
|
||||
} else if ( item.printouts.desc && item.printouts.desc.length ) {
|
||||
return item.printouts.desc[ 0 ];
|
||||
|
@ -85,8 +104,8 @@ function convertDataToResults( data ) {
|
|||
|
||||
const getThumbnail = ( item ) => {
|
||||
if ( item.printouts.thumbnail && item.printouts.thumbnail.length ) {
|
||||
const img_title = item.printouts.thumbnail[ 0 ].fulltext;
|
||||
return config.wgScriptPath + '/index.php?title=Special:Redirect/file/' + img_title + '&width=200&height=200';
|
||||
const imgTitle = item.printouts.thumbnail[ 0 ].fulltext;
|
||||
return config.wgScriptPath + '/index.php?title=Special:Redirect/file/' + imgTitle + '&width=200&height=200';
|
||||
} else { return undefined; }
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue