MediaWiki:Common.js/FairUseUpload.js

// 12:24, May 29, 2013 (UTC) // Just a get it done version

if (mediaWiki.config.get('wgCanonicalSpecialPageName') === 'MultipleUpload') { jQuery(function($) {	"use strict";	var $desc = $('#wpUploadDescription');	if ($desc.val) return; // If not empty then don't do anything (i.e. error message confirm page)	$desc.val( ''	); }); }

/** * Sets the cookie * @param c_name string Name of the cookie * @param value string 'on' or 'off' * @param expiredays integer Expiry time of the cookie in days */ function setCookie(c_name, value, expiredays) { var exdate = new Date; exdate.setDate(exdate.getDate + expiredays); document.cookie = c_name + "=" + escape(value) + ((expiredays === null) ? "" : ";expires=" + exdate.toGMTString); }

/** * Gets the cookie * @param c_name string Cookie name * @return The cookie name or empty string */ function getCookie(c_name) { if (document.cookie.length > 0) { var c_start = document.cookie.indexOf(c_name + "="); if (c_start !== -1) { c_start = c_start + c_name.length + 1; var c_end = document.cookie.indexOf(";", c_start); if (c_end === -1) { c_end = document.cookie.length; }           return unescape(document.cookie.substring(c_start, c_end)); }   }    return ""; }

if (mediaWiki.config.get('wgCanonicalSpecialPageName') === 'Upload') { setupUploadForm; }

/** * Start upload form customisations */ function setupUploadForm { // Check if cookie has been set for form style. Overrides URL parameter if set. var formstyle = getCookie("uploadform"); $("#uploadBasicLinkJS").show; $("#uploadTemplateNoJS").hide; var wpLicense = $('#wpLicense'); if (wpLicense.length && window.location.search.indexOf('wpForReUpload=1') == -1) { if (formstyle == "guided" || (formstyle == "" && window.location.search.indexOf('basic=true') == -1)) { // Add link to basic form $("#uploadtext").prepend(' Switch to basic upload form '); // Stretch table to full width $('#mw-htmlform-description').css('width', '100%'); // Bind upload button to verify function $('#mw-upload-form').bind('submit', verifySummary); var rows = $('#mw-htmlform-description').find('tr'); $('tr.mw-htmlform-field-HTMLTextAreaField').hide; $('tr.mw-htmlform-field-HTMLTextAreaField').next.detach; rows.eq(1).after(' Source:  '); var tbody1 = $('#mw-htmlform-description').children('tbody').eq(0); tbody1.append(' Description:  '); tbody1.append(' -- Optional fields -- ');

// Add new optional rows var tbody2 = $('#mw-htmlform-description').children('tbody').eq(1); tbody2.append(' Characters in image:  '); tbody2.append(' Purpose:  '); tbody2.append(' Jutsu in image: <td class="mw-input"><textarea id="jutsuBox" placeholder="[IF ANY] List of Jutsu separated by comma" cols="60" rows="2" style="overflow: auto;"> '); tbody2.append(' <td class="mw-label" style="width: 125px;">Portion Used: <td class="mw-input"><textarea id="portionBox" placeholder="[OPTIONAL] Portion of the copyright used." cols="60" rows="2" style="overflow: auto;"> '); tbody2.append(' <td class="mw-label" style="width: 125px;">Replaceable?: <td class="mw-input"><textarea id="replaceBox" placeholder="[OPTIONAL] Is the image replaceable?" cols="60" rows="2" style="overflow: auto;"> '); tbody2.append(' <td class="mw-label" style="width: 125px;">Resolution: <td class="mw-input"><textarea id="resolutionBox" placeholder="[OPTIONAL] Resolution of the image." cols="60" rows="2" style="overflow: auto;"> '); tbody2.append(' <td class="mw-label" style="width: 125px;">Other Information: <td class="mw-input"><textarea id="otherinfoBox" placeholder="[OPTIONAL] Any other information about the image." cols="60" rows="2" style="overflow: auto;"> '); } else { // Old style form just needs Information template in the summary box $('#wpUploadDescription').val('==Summary==\r\n'); // Add link to guided form $("#uploadtext").prepend(' Switch to guided upload form</a> '); }   } } function verifySummary {

// Check for licensing var wpLicense = document.getElementById('wpLicense'); if (wpLicense.value == "") { alert('Licensing must be completed.'); return false; }   // Check for source if (document.getElementById('sourceBox').value == "") { alert('Source must be completed.'); return false; }

// Check for Description if (document.getElementById('descriptionBox').value == "") { alert('Description must be completed.'); return false; }   var strBuilder = ''; document.getElementById('wpUploadDescription').value = strBuilder; return true; }