// results that have previously been cached in the opts and warn
// objects. The actual checking is done in the event handler
// of the file input boxes.
fuwGlobal.prototype.hasValidFilename = function {
var opts = this.opts;
var warn = this.warn;
var valid =
opts.InputName &&
opts.InputFilename &&
!warn.BadFilename &&
!warn.ImageOnCommons &&
// if image exists on enwiki, accept only if user has confirmed overwrite:
!(warn.ImageExists && !(opts.OverwriteSame || opts.OverwriteDifferent));
//alert("HasValidFilename: " + valid);
return valid;
};  
// ============================================================
// validation status for common input elements for all free
// options
// ============================================================
fuwGlobal.prototype.hasValidCommonFreeInput = function {
var opts = this.opts;
var warn = this.warn;
var valid = opts.InputDesc;
//alert("HasValidCommonFreeInput: " + valid);
return valid;
};
// ============================================================
// validation status for common input elements for all non-free
// options
// ============================================================
fuwGlobal.prototype.hasValidCommonNFInput = function {
var opts = this.opts;
var warn = this.warn;
var valid =
opts.OptionNonFree &&
opts.InputDesc &&
opts.NFArticle &&
opts.Source &&
opts.NFMinimality &&
!warn.NFArticleNotFound &&
!warn.NFArticleNotMainspace &&
!warn.NFArticleDab;
//alert("hasValidCommonNFInput: " + valid);
return valid;
};
// ============================================================
// Main validation routine. Modify this to tweak which fields
// are to be considered obligatory for each case group
// ============================================================
fuwGlobal.prototype.validateInput = function {
var opts = this.opts;
var warn = this.warn;
var valid = (
this.hasValidFilename
&&
(! (opts.OverwriteDifferent && ! opts.EditSummary))
&&
(
( // overwriting is okay if there is an edit summary
opts.OverwriteSame && opts.EditSummary
( // free options
this.hasValidCommonFreeInput &&
(
(opts.OptionOwnWork &&
opts.Date &&
opts.OwnWorkLicense)
(opts.OptionThirdParty &&
opts.Author &&
opts.Source &&
opts.Permission &&
(opts.ThirdPartyOtherLicense || opts.ThirdPartyLicense) &&
((opts.ThirdPartyEvidenceOptionLink && opts.ThirdPartyEvidenceLink) ||
opts.ThirdPartyEvidenceOptionOTRS ||
opts.ThirdPartyEvidenceOptionOTRSForthcoming ||
opts.ThirdPartyEvidenceOptionNone))
(opts.OptionFreeWebsite &&
opts.Author &&
opts.Source &&
(opts.FreeWebsiteOtherLicense || opts.FreeWebsiteLicense) &&
opts.Permission)
(opts.OptionPDOld &&
opts.Author &&
opts.PDOldAuthorLifetime &&
opts.Publication &&
opts.Date &&
opts.Source &&
opts.PDOldOptions &&
(! (opts.PDOldOther && ! opts.PDOldPermission)))
(opts.OptionPDOther &&
opts.Author &&
opts.Source &&
((opts.PDOtherUSGov && opts.USGovLicense) ||
(opts.PDOtherOfficial && opts.PDOfficialPermission) ||
(opts.PDOtherSimple && opts.IneligibleLicense) ||
(opts.PDOtherOther && opts.PDOtherPermission)))
) // end of free options
( // non-free options
this.hasValidCommonNFInput &&
(
(opts.OptionNFSubject &&
opts.NFSubjectLicense &&
opts.Author &&
(opts.NFSubjectCheckDedicated ||
(opts.NFSubjectCheckDiscussed && opts.NFSubjectPurpose)))
(opts.OptionNF3D &&
opts.NF3DLicense &&
opts.NF3DCreator &&
opts.Author &&
(opts.NF3DOptionSame ||
(opts.NF3DOptionFree || opts.NF3DPermission)) &&
(opts.NF3DCheckDedicated ||
(opts.NF3DCheckDiscussed && opts.NF3DPurpose)))
(opts.OptionNFExcerpt &&
opts.NFExcerptLicense &&
opts.Author &&
opts.NFPurpose)
(opts.OptionNFCover &&
opts.NFCoverLicense &&
opts.Author &&
opts.NFCoverCheckDedicated
(opts.OptionNFLogo &&
opts.NFLogoLicense &&
opts.NFLogoCheckDedicated
(opts.OptionNFPortrait &&
opts.Publication &&
opts.NFPortraitDeceased &&
opts.Author &&
opts.NFPortraitCheckDedicated &&
opts.NFReplaceable &&
opts.NFCommercial)
(opts.OptionNFMisc &&
opts.NFMiscLicense &&
opts.Author &&
opts.Publication &&
opts.NFPurpose &&
opts.NFReplaceableText &&
opts.NFReplaceable &&
opts.NFCommercial)
) // end of non-free options
);
return valid;
};  
// =============================================================
// return which template name will be used as the main
// description template
// =============================================================
fuwGlobal.prototype.getDescriptionTemplateName = function {
// standard "Information" template for free files:
if (this.opts.OptionFree) return "Information";
// experimental new version of fair-use rationale template,
// designed to fit the fields used in the wizard
else if (this.opts.OptionNonFree) return "Non-free use rationale 2";
return undefined;
};  
// =============================================================
// get the license tag code from the appropriate input element
// =============================================================  
fuwGlobal.prototype.getStandardLicense = function {
var opts = this.opts;  
}  
fuwGlobal.prototype.getLicense = function {
var opts = this.opts;
// ThirdParty and FreeWebsite have alternative input fields
// for manual entry of other licenses:
var license = {};
if (opts.PDOtherOther || opts.PDOldOther) {
license.special = opts.PDOtherOther ? opts.PDOtherPermission : opts.PDOldPermission;
if (! (license.special.match(/^\s*\{\{.+\}\}\s*$/))) {
license.special = '';
}
}
else {
license.special =
opts.ThirdPartyOtherLicense ||
opts.FreeWebsiteOtherLicense ||
(opts.PDOtherOfficial ? ('') : null) ||
(opts.OptionNFPortrait ? ('') : null);
}
if (! license.special) {
// standard, non-parametrized tag licenses from dropdownbox.
var simpleLicense = (opts.OptionOwnWork ? opts.OwnWorkLicense : null) ||
(opts.OptionThirdParty ? opts.ThirdPartyLicense : null) ||
(opts.OptionFreeWebsite ? opts.FreeWebsiteLicense : null) ||
(opts.OptionNFSubject ? opts.NFSubjectLicense : null) ||
(opts.OptionNF3D ? opts.NF3DLicense : null) ||
(opts.OptionNFExcerpt ? opts.NFExcerptLicense : null) ||
(opts.OptionNFCover ? opts.NFCoverLicense : null) ||
(opts.OptionNFLogo ? opts.NFLogoLicense : null) ||
(opts.OptionNFMisc ? opts.NFMiscLicense : null) ||
(opts.PDOtherUSGov ? opts.USGovLicense : null) ||
(opts.PDOtherSimple ? opts.IneligibleLicense : null) ||
(opts.PDUS1923 ? 'PD-US-1923' : null) ||
(opts.PDURAA ? 'PD-URAA' : null) ||
(opts.PDFormality ? 'PD-US' : null);  
// "PD-author" needs parameter, at least on Commons
if (simpleLicense == 'PD-author') {
license.special = '';
}
else if (this.knownCommonsLicenses[simpleLicense]) {
// make sure we send only those licenses as "standard" licenses
// that exist in the Commons license dropdown box
license.standard = simpleLicense;
}
else {
license.special = '\{\{' + simpleLicense + '\}\}';
}
}
return license;
};  
function fuwSubst(template) {
return '';
}  
// ===================================================================
// Produce code for local tracking categories
// ===================================================================
fuwGlobal.prototype.getTrackingCategory = function {
var opts = this.opts;
var cat = "";
if (opts.OptionFreeWebsite) { cat = "Files from freely licensed external sources"; }
else if (opts.OptionThirdParty) { cat = "Files licensed by third parties"; }
else if (opts.PDOtherOther || opts.PDOldOther) { cat = "Files with non-standard public domain statements"; }
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;
};  
// ===================================================================
// Get or create an edit summary for the upload
// ===================================================================
// Note: if we work with the api.php interface, we can have separate
// data for the edit summary and the description page, which is far
// better than the way the index.php interface does it.