MediaWiki:Common.js/FairUseUpload.js

/** * 13:00, August 4, 2014 (UTC) * http://naruto.wikia.com/wiki/MediaWiki:Common.js/FairUseUpload.js * Builds a form for easy uploading of images * and to ensure proper rationale and licensing * @author: UltimateSupreme (http://naruto.wikia.com/wiki/User:UltimateSupreme) * @License: CC-BY-SA - http://creativecommons.org/licenses/by-sa/3.0/ * @TO-DO: Make source-box code cleaner

/* global mw, dev */ if (mw.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( ''       );    }); }

/** * Start upload form customisations */

if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload') { if (!$.getUrlVar('wpForReUpload')) { jQuery(function($) {           'use strict';            var $description = $('#wpUploadDescription'),                customRows = '',                sourceInfo,                $customRows,                sourcehtml = ' ' +                'Source: ' +                '' +                'Manga' +                'Anime ' +                ' ' +

' ' +               'Chapter: ' + ' ' + ' Page: ' + '' + ' ' +

'' + 'Episode: ' + ' ' + 'Shippuden ' + ' ';

if ($description.val) { return; // error message confirm page }

function fromTemplate(name, id, required, title, elem) { elem = elem || ' '; return ' \n' + '<td class="mw-label"><label style= "cursor: help;" for="' + id + (title ? '" title="' + title : '') + '">' + name + ': \n' + '<td class="mw-input">' + elem + ' \n' + ' \n'; }

customRows += fromTemplate('Description', 'descriptionBox', true, '[REQUIRED] Describe what is happening and why it\'s important.'); customRows += sourcehtml; customRows += fromTemplate('Characters in image', 'characterBox', false, '[IF ANY] List of Characters separated by comma.'); customRows += fromTemplate('Jutsu in image', 'jutsuBox', false, '[IF ANY] List of Jutsu separated by comma.'); customRows += fromTemplate('Purpose', 'purposeBox', false, '[OPTIONAL] Purpose of this image.'); customRows += fromTemplate('Portion Used', 'portionBox', false, '[OPTIONAL] Portion of the copyright used.'); customRows += fromTemplate('Replaceable?', 'replaceBox', false, '[OPTIONAL] Is the image replaceable?'); customRows += fromTemplate('Resolution', 'resolutionBox', false, '[OPTIONAL] Resolution of the image.'); customRows += fromTemplate('Other Information', 'otherinfoBox', false, '[OPTIONAL] Any other information about the image.');

// To real DOM $customRows = $(customRows); $description.closest('tr').hide.after($customRows); $customRows.find("textarea, input").tooltip({               trigger: 'focus'            });

$customRows.find("input[name='source']").change(function {               $("#animeinfo, #mangainfo").toggle;            });

function verifySummary { if (!$('#wpLicense').val) { window.alert('Licensing must be complete.'); return false; }

if (!$.trim($customRows.find('#descriptionBox').val).length) { window.alert('Please enter a proper description for your image.'); return false; }

if ($customRows.find("input[name='source']:checked").val === "Anime" && !$.trim($customRows.find('#episodeno').val).length) { window.alert('Please enter the source of your image (exact episode number).'); return false; }

if ($customRows.find("input[name='source']:checked").val === "Manga" && !($.trim($customRows.find('#chapterno').val).length && $.trim($customRows.find('#pageno').val).length)) { window.alert('Please enter the source of your image (exact chapter and page number).'); return false; }

var template = '', resolution = $.trim($customRows.find('#resolutionBox').val); if (/1080p/i.test(resolution)) { template = '\n'; } else if (/720p/i.test(resolution)) { template = '\n'; }

if ($customRows.find("input[name='source']:checked").val === "Manga") sourceInfo = "Manga, Chapter " + $customRows.find("#chapterno").val + ", page: " + $customRows.find("#pageno").val; else sourceInfo = "Naruto" + ($customRows.find("#source-shippuden").is(":checked") ? " Shippuden" : "") + ", episode: " + $customRows.find("#episodeno").val;

var strBuilder = template; strBuilder += ''; $description.val(strBuilder); return true; }

// Bind submit to verify function $description.closest('form').submit(verifySummary);

// Autocomplete links $.getScript(               '/load.php?debug=false&lang=en&mode=articles&skin=oasis&missingCallback=importArticleMissing&articles=u%3Acamtest%3AMediaWiki%3ATextareaHelper.js%7Cu%3Adev%3AColors%2Fcode.js%7Cu%3Adev%3AMiniComplete%2Fcode.js&only=scripts', function {                    dev.minicomplete.load( $customRows.find('#descriptionBox'), $customRows.find('#sourceBox') );               });        });    } }