}
// Check response cache
if ( this.responseCache.hasOwnProperty( this.nameToCheck ) ) {
- this.setWarning( this.responseCache[this.nameToCheck] );
+ this.setWarning( this.responseCache[ this.nameToCheck ] );
return;
}
} ).done( function ( result ) {
var resultOut = '';
if ( result.query ) {
- resultOut = result.query.pages[result.query.pageids[0]].imageinfo[0];
+ resultOut = result.query.pages[ result.query.pageids[ 0 ] ].imageinfo[ 0 ];
}
$spinnerDestCheck.remove();
uploadWarning.processResult( resultOut, uploadWarning.nameToCheck );
processResult: function ( result, fileName ) {
this.setWarning( result.html );
- this.responseCache[fileName] = result.html;
+ this.responseCache[ fileName ] = result.html;
},
setWarning: function ( warning ) {
return;
}
if ( this.responseCache.hasOwnProperty( license ) ) {
- this.showPreview( this.responseCache[license] );
+ this.showPreview( this.responseCache[ license ] );
return;
}
},
processResult: function ( result, license ) {
- this.responseCache[license] = result.parse.text['*'];
- this.showPreview( this.responseCache[license] );
+ this.responseCache[ license ] = result.parse.text[ '*' ];
+ this.showPreview( this.responseCache[ license ] );
},
showPreview: function ( preview ) {
fname = fname.replace( / /g, '_' );
// Capitalise first letter if needed
if ( mw.config.get( 'wgCapitalizeUploads' ) ) {
- fname = fname[0].toUpperCase() + fname.slice( 1 );
+ fname = fname[ 0 ].toUpperCase() + fname.slice( 1 );
}
// Output result
* @return boolean
*/
function fileIsPreviewable( file ) {
- var known = ['image/png', 'image/gif', 'image/jpeg', 'image/svg+xml'],
+ var known = [ 'image/png', 'image/gif', 'image/jpeg', 'image/svg+xml' ],
tooHuge = 10 * 1024 * 1024;
return ( $.inArray( file.type, known ) !== -1 ) && file.size > 0 && file.size < tooHuge;
}
* @return {string}
*/
function prettySize( s ) {
- var sizeMsgs = ['size-bytes', 'size-kilobytes', 'size-megabytes', 'size-gigabytes'];
+ var sizeMsgs = [ 'size-bytes', 'size-kilobytes', 'size-megabytes', 'size-gigabytes' ];
while ( s >= 1024 && sizeMsgs.length > 1 ) {
s /= 1024;
sizeMsgs = sizeMsgs.slice( 1 );
}
- return mw.msg( sizeMsgs[0], Math.round( s ) );
+ return mw.msg( sizeMsgs[ 0 ], Math.round( s ) );
}
/**
.find( '.thumbinner' ).prepend( $spinner ).end();
$canvas = $( '<canvas>' ).attr( { width: previewSize, height: previewSize } );
- ctx = $canvas[0].getContext( '2d' );
+ ctx = $canvas[ 0 ].getContext( '2d' );
$( '#mw-htmlform-source' ).parent().prepend( thumb );
fetchPreview( file, function ( dataURL ) {
buffer = new Uint8Array( reader.result ),
string = '';
for ( i = 0; i < buffer.byteLength; i++ ) {
- string += String.fromCharCode( buffer[i] );
+ string += String.fromCharCode( buffer[ i ] );
}
callbackBinary( string );
function getMaxUploadSize( type ) {
var sizes = mw.config.get( 'wgMaxUploadSize' );
- if ( sizes[type] !== undefined ) {
- return sizes[type];
+ if ( sizes[ type ] !== undefined ) {
+ return sizes[ type ];
}
- return sizes['*'];
+ return sizes[ '*' ];
}
$( '.mw-upload-source-error' ).remove();
clearPreview();
if ( this.files && this.files.length ) {
// Note: would need to be updated to handle multiple files.
- var file = this.files[0];
+ var file = this.files[ 0 ];
if ( !checkMaxUploadSize( file ) ) {
return;