MediaWiki:FileUploadWizard.js: Difference between revisions
Content deleted Content added
fixing bug 39779 |
per tper |
||
(46 intermediate revisions by 14 users not shown) | |||
Line 16:
// ================================================================
function fuwGlobal() {
// see if user is logged in, autoconfirmed, experienced etc.
Line 27 ⟶ 22:
fuwSetVisible('warningLoggedOut', (this.userStatus == 'anon'));
fuwSetVisible('warningNotConfirmed', (this.userStatus == 'notAutoconfirmed'));
if (this.disabled) {
return;
}
Line 46 ⟶ 42:
this.ScriptForm = frm;
// create the TargetForm element that contains the
frm = fuwGet('TargetForm');
if (! frm) {
frm = document.createElement('form');
frm.id = "TargetForm";
var area = fuwGet('placeholderTargetForm');
var parent = area.parentNode;
Line 105 ⟶ 82:
filebox.size = fuwDefaultTextboxLength;
filebox.onchange = fuwValidateFile;
filebox.accept = 'image/png,image/jpeg,image/gif,image/svg+xml,image/tiff,image/x-xcf,application/pdf,image/vnd.djvu,audio/ogg,video/ogg,audio/rtp-midi,audio/mp3,image/webp,video/webm,audio/opus,video/mpeg,audio/wav,audio/flac';
fuwAppendInput('file', filebox);
//
this.UploadOptions = {
filename : '',
text : '',
comment : '',
ignorewarnings : 1,
watch : 1
};
if (fuwTesting) {
fuwMakeHiddenfield('title', mw.config.get('wgPageName') + "/sandbox", 'SandboxTitle');
fuwMakeHiddenfield('token', mw.user.tokens.get('
fuwMakeHiddenfield('recreate', 1, 'SandboxRecreate');
}
if (fuwTesting) {
Line 204 ⟶ 170:
'ThirdPartyEvidenceOptionNone'],
// choice of PD status in OptionPDOld subsection
'PDOldOptions' : ['
// choice of PD status in OptionPDOther subsection
'PDOtherOptions': ['PDOtherUSGov','PDOtherOfficial','PDOtherSimple',
Line 274 ⟶ 240:
[
['Allow all use as long as others credit you and share it under similar conditions'],
['self|GFDL|cc-by-sa-
'Creative Commons Attribution-Share Alike
true],
['self|cc-by-sa-
'Creative Commons Attribution-Share Alike
[],
['Allow all use as long as others credit you'],
['self|cc-by-
'Creative Commons Attribution
[],
['Reserve no rights'],
['
'
[]
],
Line 293 ⟶ 259:
['', 'please select the correct license...'],
['Freely licensed:'],
['cc-by-sa-4.0', 'Creative Commons Attribution-Share Alike (cc-by-sa-4.0)'],
['cc-by-4.0', 'Creative Commons Attribution (cc-by-4.0)'],
['GFDL', 'GNU Free Documentation License (GFDL)'],
[],
Line 307 ⟶ 273:
['', 'please select the correct license...'],
['Freely licensed:'],
['cc-by-sa-4.0', 'Creative Commons Attribution-Share Alike (cc-by-sa-4.0)'],
['cc-by-4.0', 'Creative Commons Attribution (cc-by-4.0)'],
['GFDL', 'GNU Free Documentation License (GFDL)'],
[],
Line 322 ⟶ 288:
['PD-USGov-NASA','NASA'],
['PD-USGov-Military-Navy','US Navy'],
['PD-USGov-DOC-NOAA','US National Oceanic and Atmospheric Administration'],
['PD-USGov-Military-Air_Force','US Air Force'],
['PD-USGov-Military-Army','US Army'],
['PD-USGov-
],
'IneligibleLicense' :
Line 332 ⟶ 297:
['', 'please select one...'],
['PD-shape','Item consists solely of simple geometric shapes'],
['PD-
['PD-textlogo','Logo or similar item consisting solely of letters and simple geometric shapes'],
['PD-chem','Chemical structural formula'],
Line 341 ⟶ 306:
['', 'please select one...'],
['Non-free 2D art', '2-dimensional artwork (painting, drawing etc.)'],
['Non-free historic image', '
['Non-free fair use
],
'NF3DLicense' :
[
[
['Non-free
['Non-free destroyed architecture', 'Destroyed (or unrecognizably altered) architecture'],
['Non-free 3D art', 'Other 3-dimensional creative work (sculpture etc.)']
],
Line 355 ⟶ 321:
['Non-free book cover', 'Cover page of a book'],
['Non-free album cover', 'Cover of a sound recording (album, single, song, CD)'],
['Non-free video game cover', 'Cover of a video/computer game'],
['Non-free magazine cover', 'Cover page of a magazine'],
['Non-free video cover', 'Cover of a video'],
Line 361 ⟶ 327:
['Non-free product cover', 'Cover of some commercial product'],
['Non-free title-card', 'Title screen of a TV programme'],
['Non-free
['Non-free poster', 'Official poster of an event'],
['Non-free fair use
],
'NFExcerptLicense' :
Line 370 ⟶ 336:
['Non-free television screenshot', 'Television screenshot'],
['Non-free film screenshot', 'Movie screenshot'],
['Non-free video game screenshot', '
['Non-free video screenshot', 'Video screenshot'],
['Non-free music video screenshot', 'Music video screenshot'],
Line 382 ⟶ 348:
['Non-free computer icon', 'Computer icon'],
['Non-free newspaper image', 'Page from a newspaper'],
['Non-free fair use
],
'NFLogoLicense' :
Line 435 ⟶ 401:
['Non-free New Zealand Crown Copyright', 'NZ Crown Copyright'],
['Non-free Canadian Crown Copyright', 'Canadian Crown Copyright'],
['Non-free AUSPIC', 'AUSPIC (Australian Parliament image database)'],
['Non-free Philippines government', 'Philippines government'],
['Non-free Finnish Defence Forces', 'Finnish Defence Forces'],
[],
['Other individual sources'],
['Non-free Denver Public Library image', 'Denver Public Library'],
['Non-free ESA media', 'ESA (European Space Agency)'],
[],
Line 449 ⟶ 415:
['Some permissions granted, but not completely free'],
['Non-free promotional', 'From promotional press kit'],
['Non-free file with
['Non-free file with
['Non-free with permission', 'Permission granted, but only for Wikipedia'],
[]
Line 464 ⟶ 430:
'self|Cc-zero' : 1,
'PD-self' : 1,
'self|GFDL|cc-by-sa-4.0|migration=redundant' : 1,
'self|GFDL|cc-by-4.0|migration=redundant' : 1,
'self|GFDL|cc-by-sa-3.0|migration=redundant' : 1,
'self|GFDL|cc-by-3.0|migration=redundant' : 1,
'self|cc-by-sa-4.0' : 1,
'self|cc-by-sa-3.0' : 1,
'cc-by-sa-4.0' : 1,
'cc-by-sa-3.0' : 1,
'cc-by-sa-2.5' : 1,
'cc-by-4.0' : 1,
'cc-by-3.0' : 1,
'cc-by-2.5' : 1,
Line 886 ⟶ 857:
opts.Source &&
opts.PDOldOptions &&
(! (opts.PDOldOther && ! opts.PDOldPermission)))
||
(opts.OptionPDOther &&
Line 895 ⟶ 866:
(opts.PDOtherSimple && opts.IneligibleLicense) ||
(opts.PDOtherOther && opts.PDOtherPermission)))
)
) // end of free options
Line 1,009 ⟶ 979:
(opts.PDOtherUSGov ? opts.USGovLicense : null) ||
(opts.PDOtherSimple ? opts.IneligibleLicense : null) ||
(opts.
(opts.PDURAA ? 'PD-URAA' : null) ||
(opts.PDFormality ? 'PD-US' : null);
Line 1,023 ⟶ 993:
}
else {
license.special = '\{\{' + simpleLicense + '\}\}';
}
}
Line 1,044 ⟶ 1,014:
else if (opts.OptionNFSubject || opts.OptionNF3D) { cat = "Non-free files uploaded as object of commentary"; }
if (cat) {
cat = "\n\{\{Category ordered by date|" + cat + "|" +
fuwSubst("CURRENTYEAR") + "|" + fuwSubst("CURRENTMONTH") + "|" + fuwSubst("CURRENTDAY2") + "\}\}";
}
return cat;
Line 1,147 ⟶ 1,117:
"<br/>\n",
fuwSurroundString("'''Previously published:''' ", opts.OwnWorkPublication)]);
var username = mw.user.
descFields.Author = '[[User:' + username + '|' + username + ']]';
break;
Line 1,160 ⟶ 1,130:
(opts.ThirdPartyEvidenceOptionOTRS ?
("The license agreement has been forwarded to OTRS." +
fuwSurroundString(" Ticket: ", opts.ThirdPartyOTRSTicket) + "\{\{OTRS pending
"|month=" + fuwSubst("CURRENTMONTH") +
"|day=" + fuwSubst("CURRENTDAY2") + "\}\}") :
(opts.ThirdPartyEvidenceOptionOTRSForthcoming ?
"The license agreement will be forwarded to OTRS shortly. \{\{OTRS pending
"|month=" + fuwSubst("CURRENTMONTH") +
"|day=" + fuwSubst("CURRENTDAY2") + "\}\}" :
(opts.ThirdPartyEvidenceOptionNone ?
"Will be provided on request." : null))));
Line 1,224 ⟶ 1,198:
"<br/>\n" + opts.NFSubjectPurpose) : null)
);
descFields.Replaceability = "Any derivative work based upon the artwork would be a copyright violation, so creation of a free image is not possible.";
descFields.Commercial = "The use of a low resolution image of the artwork will not impact the commercial viability of the art.";
break;
Line 1,254 ⟶ 1,226:
"<br/>\n" + opts.NF3DPurpose) : null)
);
descFields.Replaceability = "
descFields.Commercial = "The use
descFields["Other information"] = (
opts.NF3DOptionSame ?
Line 1,272 ⟶ 1,244:
descFields.Purpose = opts.NFPurpose;
descFields.Replaceability_text = opts.NFReplaceableText;
descFields.Replaceability = "
descFields.Commercial = "The use of
break;
Line 1,281 ⟶ 1,253:
"to serve as the primary means of visual identification " +
"at the top of the article dedicated to the work in question.";
descFields.Replaceability = "
descFields.Commercial = "The use of
break;
Line 1,290 ⟶ 1,262:
"to serve as the primary means of visual identification " +
"at the top of the article dedicated to the entity in question.";
descFields.Replaceability = "
descFields.Commercial = "The use of
break;
Line 1,304 ⟶ 1,276:
descFields.Purpose =
"for visual identification of the person in question, " +
"at the top of
descFields.Replaceability = opts.NFReplaceable;
descFields.Commercial = opts.NFCommercial;
Line 1,316 ⟶ 1,288:
"'''Original publication''': ",
opts.Publication,
"<br/>\n'''Immediate source:''' "),
"",
opts.Source
Line 1,338 ⟶ 1,310:
descFields['Other information'],
"<br/>\n",
fuwSurroundString('\{\{', opts.NFExtraLicense, '\}\}'),
"<br/>\n",
opts.AnyOther
Line 1,414 ⟶ 1,386:
summary +
"\n==Licensing==\n" +
(license.standard ? ("\{\{" + license.standard + "\}\}") : license.special) +
this.getTrackingCategory();
Line 1,425 ⟶ 1,397:
fuwSetVisible('placeholderTestForm', true);
}
//
this.UploadOptions.filename = opts.InputName;
this.UploadOptions.text = summary;
this.UploadOptions.comment = editSummary;
}
Line 1,438 ⟶ 1,408:
function fuwHasUserGroup(group) {
// workaround because old IE versions don't have array.indexOf :-(
for (i = 0; i < mw.config.get('wgUserGroups').length; i++) {
if (mw.config.get('wgUserGroups')[i] == group) {
return true;
}
Line 1,457 ⟶ 1,427:
// 'sysop'
if (mw.config.get('wgUserName')) {
if (fuwHasUserGroup('sysop')) {
this.userStatus = 'sysop';
Line 1,474 ⟶ 1,444:
uiprop: 'editcount',
prop : 'revisions',
titles: 'User talk' + mw.config.get('wgUserName'),
rvprop: 'comment|user',
rvlimit: 30
Line 1,628 ⟶ 1,598:
place.appendChild(anchor);
}
anchor.href = mw.util.
anchor.title = target;
anchor.innerHTML = target;
Line 1,692 ⟶ 1,662:
}
else {
alert("Element not found: " +
}
}
Line 1,711 ⟶ 1,681:
}
}
} catch (e) { alert("Element not found: " + (
}
Line 1,750 ⟶ 1,720:
name = name.replace(/_/g, " ");
// uppercase first letter
name =
}
if (oldname != name) {
Line 1,809 ⟶ 1,779:
var nameBox = window.fuw.ScriptForm.InputName;
var name = $.trim(nameBox.value);
name = name.replace(/\.(png|gif|jpg|jpeg|xcf|pdf|mid|ogg|ogv|svg|djvu|tiff|tif|oga|mp3|webp|webm|opus|mpg|mpeg|wav|wave|flac)$/i, "");
// name should be at least 10 characters long, excluding file type extension
Line 1,842 ⟶ 1,812:
if (!file || !name) return true;
var extensions = /.+\.(png|gif|jpg|jpeg|xcf|pdf|mid|ogg|ogv|svg|djvu|tiff|tif|oga|mp3|webp|webm|opus|mpg|mpeg|wav|wave|flac)$/i;
var mimetypes = {
"png" : "image/png",
Line 1,849 ⟶ 1,819:
"jpeg" : "image/jpeg",
"xcf" : "image/x-xcf",
"webp" : "image/webp",
"pdf" : "application/pdf",
"mid" : "audio/rtp-midi",
"ogg" : "audio/ogg",
"mp3" : "audio/mp3",
"opus" : "audio/opus",
"wav" : "audio/wav",
"wave" : "audio/wav",
"flac" : "audio/flac",
"ogv" : "video/ogg",
"svg" : "image/svg+xml",
Line 1,857 ⟶ 1,833:
"tiff" : "image/tiff",
"tif" : "image/tiff",
"oga" : "video/ogg",
"webm" : "video/webm",
"mpg" : "video/mpeg",
"mpeg" : "video/mpeg"
};
Line 2,169 ⟶ 2,148:
// ========================================================
//
// TO DO: expand stub to add real notification of success,
// link to new file page, instructions about how to include
// file in articles, etc.
// ========================================================
function fuwUploadCompleted(doc) {
if (doc) {
//alert(doc);
Line 2,253 ⟶ 2,220:
});
fuwMakeWikilink(
fuwGet('
'File:' + name);
fuwGet('placeholderExFilename1').innerHTML = name;
Line 2,278 ⟶ 2,245:
alert("Unknown error: upload may have failed.");
}
}
}
Line 2,300 ⟶ 2,255:
var fuw = window.fuw;
fuw.collectInput();
fuw.formatOutput(false);
if (fuwTesting) {
Line 2,323 ⟶ 2,263:
}
fuwSetVisible('UploadScriptArea', false);
fuwMakeWikilink(
fuwGet('fuwSuccessLink').getElementsByTagName('a')[0], 'File:' + fuw.opts.InputName);
fuwSetVisible('fuwWaiting', true);
// Upload the file, then add success notification etc.
// Note that mw.Api doesn't have special support for the XML format, so even when the API
// returns an error, this won't be detected and it will call the success handler.
var api = new mw.Api({
parameters : { format : 'xml' },
ajax : { dataType : 'xml' }
});
api.upload(fuw.TargetForm.file, fuw.UploadOptions).then(fuwUploadCompleted);
var opts = window.fuw.opts;
// the API won't overwrite the description page text while overwriting
Line 2,340 ⟶ 2,291:
action : 'edit',
title : 'File:' + opts.InputName,
token : mw.user.tokens.get('
summary : opts.EditSummary,
text :
}
Line 2,374 ⟶ 2,325:
action: 'edit',
title : mw.config.get('wgPageName') + "/sandbox",
token : mw.user.tokens.get('
recreate : 1,
summary : frm.SandboxSummary.value,
Line 2,393 ⟶ 2,344:
// ========================================================
function fuwGet(target) {
if
else {
var found = $('#' + target);
Line 2,404 ⟶ 2,355:
// onload hook function, loading this script
// ========================================================
$(function() {
if (fuwGet('UploadScriptArea')) { window.fuw = new fuwGlobal();
if (! window.fuw.disabled) {
fuwUpdateOptions();
}
}
});
});
|