Completed
Push — master ( 48889d...507809 )
by Stephan
02:32
created

res/ext.SimpleBatchUpload.js (7 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
/**
2
 * File containing the SimpleBatchUpload class
3
 *
4
 * @copyright (C) 2016, Stephan Gambke
5
 * @license   GNU General Public License, version 2 (or any later version)
6
 *
7
 * This software is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License
9
 * as published by the Free Software Foundation; either version 2
10
 * of the License, or (at your option) any later version.
11
 * This software is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
17
 *
18
 * @file
19
 * @ingroup SimpleBatchUpload
20
 */
21
22
;( function ( $, mw, undefined ) {
0 ignored issues
show
The parameter undefined is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
23
24
	'use strict';
25
26
	$( function () {
27
		$( '#fileupload' ).fileupload( {
28
			dataType: 'json',
29
			dropZone: $( '#fileupload-dropzone' ),
30
31
			add: function ( e, data ) {
32
33
				var status = $('<li>').text( data.files[0].name );
34
				$( '#fileupload-results' ).append( status );
35
36
				data.formData = {
37
					format: 'json',
38
					action: 'upload',
39
					token: $( this ).fileupload( 'option', 'token' ),
40
					ignorewarnings: 1,
41
					filename: data.files[ 0 ].name
42
				};
43
44
				var jqXHR = data.submit()
0 ignored issues
show
The variable jqXHR seems to be never used. Consider removing it.
Loading history...
45
					.success( function ( result, textStatus, jqXHR ) {
0 ignored issues
show
The parameter jqXHR is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
The parameter textStatus is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
46
						var link = $('<a>');
47
						link
48
							.attr( 'href', mw.Title.makeTitle( mw.config.get( 'wgNamespaceIds' ).file, result.upload.filename ).getUrl() )
49
							.text( result.upload.filename );
50
51
						status
52
							// .empty()
53
							.addClass('ful-success')
54
							.text( ' OK' )
55
							.prepend( link );
56
57
					} )
58
					.error( function ( jqXHR, textStatus, errorThrown ) {
0 ignored issues
show
The parameter textStatus is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
The parameter errorThrown is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
The parameter jqXHR is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
59
						status.text( status.text() + " ERROR").addClass('ful-error');
60
					} );
61
62
			}
63
		} );
64
65
		$(document).bind('drop dragover', function (e) {
66
			e.preventDefault();
67
		});
68
	} );
69
70
}( jQuery, mediaWiki ));
71