MediaWiki:FileUploadWizard.js: Difference between revisions
Content deleted Content added
css load has been moved to a ?withCSS call |
per tper |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 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 101 ⟶ 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) {
Line 119 ⟶ 99:
fuwMakeHiddenfield('recreate', 1, 'SandboxRecreate');
}
if (fuwTesting) {
Line 318 ⟶ 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 328 ⟶ 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 338 ⟶ 307:
['Non-free 2D art', '2-dimensional artwork (painting, drawing etc.)'],
['Non-free historic image', 'Unique historic photograph'],
['Non-free fair use
],
'NF3DLicense' :
Line 352 ⟶ 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 358 ⟶ 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 367 ⟶ 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 379 ⟶ 348:
['Non-free computer icon', 'Computer icon'],
['Non-free newspaper image', 'Page from a newspaper'],
['Non-free fair use
],
'NFLogoLicense' :
Line 446 ⟶ 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 1,428 ⟶ 1,397:
fuwSetVisible('placeholderTestForm', true);
}
//
this.UploadOptions.filename = opts.InputName;
this.UploadOptions.text = summary;
this.UploadOptions.comment = editSummary;
}
Line 1,812 ⟶ 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,845 ⟶ 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,852 ⟶ 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,861 ⟶ 1,833:
"tiff" : "image/tiff",
"tif" : "image/tiff",
"oga" : "video/ogg",
"webm" : "video/webm",
"mpg" : "video/mpeg",
"mpeg" : "video/mpeg"
};
Line 2,173 ⟶ 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,282 ⟶ 2,245:
alert("Unknown error: upload may have failed.");
}
}
}
Line 2,304 ⟶ 2,255:
var fuw = window.fuw;
fuw.collectInput();
fuw.formatOutput(false);
if (fuwTesting) {
Line 2,332 ⟶ 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,349 ⟶ 2,293:
token : mw.user.tokens.get('csrfToken'),
summary : opts.EditSummary,
text :
}
Line 2,411 ⟶ 2,355:
// onload hook function, loading this script
// ========================================================
$(function() {
if (fuwGet('UploadScriptArea')) { window.fuw = new fuwGlobal();
if (! window.fuw.disabled) {
fuwUpdateOptions();
}
}
});
});
|