User:Recludam/common.js

/*** BEGIN customized upload form ***/ function setupUploadForm { var wpLicense = $('#wpLicense'); // If the user isn't reuploading a file... if ( wpLicense.length && window.location.search.indexOf('wpForReUpload=1') == -1) { // Stretch table to full width $('#mw-htmlform-description').css('width', '100%'); // Bind upload button to checkOverall function $('#mw-upload-form').bind('submit', checkOverall); // Hide existing rows var rows = $('#mw-htmlform-description').find('tr'); $('tr.mw-htmlform-field-HTMLTextAreaField').hide; $('tr.mw-htmlform-field-HTMLTextAreaField').next.detach; $('#mw-htmlform-description').addClass('hidable start-hidden'); // Add new required row(s) var tbody1 = $('#mw-htmlform-description').children('tbody').eq(0); tbody1.append(' Categories:  '); } else { $('#mw-upload-form').bind('submit', checkFilename); } } function checkOverall{ var wpLicense = document.getElementById('wpLicense'); var wpDestFile = document.getElementById('wpDestFile'); // Check for licensing if ( wpLicense.value === "" ){ alert('Licensing must be completed.'); return false; }	// Check for duplicated or capitalized file extensions if ( wpDestFile.value.match(/(JPG|PNG|GIF|SVG|jpg\.jpg|png\.png|gif\.gif|svg\.svg)$/)) { alert('Please do not use capitalized or duplicated file extensions in the filename.'); return false; }   var categories = document.getElementById('catsBox').value.replace(/,/g, '|').replace(/\s/g, '') + '|'; var fileinfo = ''; //document.getElementById('wpUploadDescription').value = fileinfo; $('#wpUploadDescription').val(fileinfo); wpLicense.selectedIndex = 0; return true; } function checkFilename{ var wpDestFile = document.getElementById( 'wpDestFile' ); var wpLicense = document.getElementById( 'wpLicense' ); // Check for underscores and spaces if ( wpDestFile.value.match(/( |_)$/)) { alert('Please consider replacing underscores and spaces with hyphens.'); return false; }	// Check for duplicated or capitalized file extensions if ( wpDestFile.value.match(/(JPG|PNG|GIF|SVG|jpg.jpg|png.png|gif.gif|svg.svg)$/)) { alert('Please do not use capitalized or duplicated file extensions in the filename.'); return false; }	// Check for annoying characters if ( wpDestFile.value.match(/(\(|\)|!|\?|,|\+|\'|\’)/)) { alert('Please do not use parantheses, slashes, punctuation marks, or other non-alphanumeric characters in your filename.'); return false; }	// Check if license has been changed if ( wpLicense.value !== '' ) { $( '#wpUploadDescription' ).val(			$( '#wpUploadDescription' ).val.replace( '| license   = ', '| license    = ' + wpLicense.options[wpLicense.selectedIndex].title )		); wpLicense.selectedIndex = 0; }	return true; } /*** END customized upload form ***/ if ( wgCanonicalSpecialPageName === 'Upload' ) { setupUploadForm; }