1 ( function ( mw
, OO
) {
3 * @class mw.ForeignUpload
6 * Used to represent an upload in progress on the frontend.
8 * Subclassed to upload to a foreign API, with no other goodies. Use
9 * this for a generic foreign image repository on your wiki farm.
11 * Note you can provide the {@link #targetHost targetHost} or not - if the first argument is
12 * an object, we assume you want the default, and treat it as apiconfig
16 * @param {string} [targetHost="commons.wikimedia.org"] Used to set up the target
17 * wiki. If not remote, this class behaves identically to mw.Upload (unless further subclassed)
18 * @param {Object} [apiconfig] Passed to the constructor of mw.ForeignApi or mw.Api, as needed.
20 function ForeignUpload( targetHost
, apiconfig
) {
23 if ( typeof targetHost
=== 'object' ) {
24 // targetHost probably wasn't passed in, it must
26 apiconfig
= targetHost
;
28 // targetHost is a useful string, set it here
29 this.targetHost
= targetHost
|| this.targetHost
;
32 if ( location
.host
!== this.targetHost
) {
33 api
= new mw
.ForeignApi(
34 location
.protocol
+ '//' + this.targetHost
+ '/w/api.php',
38 // We'll ignore the CORS and centralauth stuff if we're on Commons already
39 api
= new mw
.Api( apiconfig
);
42 mw
.Upload
.call( this, api
);
45 OO
.inheritClass( ForeignUpload
, mw
.Upload
);
48 * @property targetHost
49 * Used to specify the target repository of the upload.
51 * You could override this to point at something that isn't Commons,
52 * but be sure it has the correct templates and is CORS and CentralAuth
55 ForeignUpload
.prototype.targetHost
= 'commons.wikimedia.org';
57 mw
.ForeignUpload
= ForeignUpload
;