MediaWiki:FileUploadWizard.js: Difference between revisions
Content deleted Content added
update |
per tper |
||
(29 intermediate revisions by 10 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-
['cc-by-
['GFDL', 'GNU Free Documentation License (GFDL)'],
[],
Line 307 ⟶ 273:
['', 'please select the correct license...'],
['Freely licensed:'],
['cc-by-sa-
['cc-by-
['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 342 ⟶ 307:
['Non-free 2D art', '2-dimensional artwork (painting, drawing etc.)'],
['Non-free historic image', 'Unique historic photograph'],
['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 1,008 ⟶ 979:
(opts.PDOtherUSGov ? opts.USGovLicense : null) ||
(opts.PDOtherSimple ? opts.IneligibleLicense : null) ||
(opts.
(opts.PDURAA ? 'PD-URAA' : null) ||
(opts.PDFormality ? 'PD-US' : null);
Line 1,022 ⟶ 993:
}
else {
license.special = '\{\{' + simpleLicense + '\}\}';
}
}
Line 1,043 ⟶ 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,159 ⟶ 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,223 ⟶ 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,253 ⟶ 1,226:
"<br/>\n" + opts.NF3DPurpose) : null)
);
descFields.Replaceability = "
descFields.Commercial = "The use
descFields["Other information"] = (
opts.NF3DOptionSame ?
Line 1,271 ⟶ 1,244:
descFields.Purpose = opts.NFPurpose;
descFields.Replaceability_text = opts.NFReplaceableText;
descFields.Replaceability = "
descFields.Commercial = "The use of
break;
Line 1,280 ⟶ 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,289 ⟶ 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,303 ⟶ 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,337 ⟶ 1,310:
descFields['Other information'],
"<br/>\n",
fuwSurroundString('\{\{', opts.NFExtraLicense, '\}\}'),
"<br/>\n",
opts.AnyOther
Line 1,413 ⟶ 1,386:
summary +
"\n==Licensing==\n" +
(license.standard ? ("\{\{" + license.standard + "\}\}") : license.special) +
this.getTrackingCategory();
Line 1,424 ⟶ 1,397:
fuwSetVisible('placeholderTestForm', true);
}
//
this.UploadOptions.filename = opts.InputName;
this.UploadOptions.text = summary;
this.UploadOptions.comment = editSummary;
}
Line 1,691 ⟶ 1,662:
}
else {
alert("Element not found: " +
}
}
Line 1,710 ⟶ 1,681:
}
}
} catch (e) { alert("Element not found: " + (
}
Line 1,749 ⟶ 1,720:
name = name.replace(/_/g, " ");
// uppercase first letter
name =
}
if (oldname != name) {
Line 1,808 ⟶ 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,841 ⟶ 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,848 ⟶ 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,856 ⟶ 1,833:
"tiff" : "image/tiff",
"tif" : "image/tiff",
"oga" : "video/ogg",
"webm" : "video/webm",
"mpg" : "video/mpeg",
"mpeg" : "video/mpeg"
};
Line 2,168 ⟶ 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,277 ⟶ 2,245:
alert("Unknown error: upload may have failed.");
}
}
}
Line 2,299 ⟶ 2,255:
var fuw = window.fuw;
fuw.collectInput();
fuw.formatOutput(false);
if (fuwTesting) {
Line 2,327 ⟶ 2,268:
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,342 ⟶ 2,291:
action : 'edit',
title : 'File:' + opts.InputName,
token : mw.user.tokens.get('
summary : opts.EditSummary,
text :
}
Line 2,376 ⟶ 2,325:
action: 'edit',
title : mw.config.get('wgPageName') + "/sandbox",
token : mw.user.tokens.get('
recreate : 1,
summary : frm.SandboxSummary.value,
Line 2,395 ⟶ 2,344:
// ========================================================
function fuwGet(target) {
if
else {
var found = $('#' + target);
Line 2,406 ⟶ 2,355:
// onload hook function, loading this script
// ========================================================
$(function() {
if (fuwGet('UploadScriptArea')) { window.fuw = new fuwGlobal();
if (! window.fuw.disabled) {
fuwUpdateOptions();
}
}
});
});
|