MediaWiki:Upload.js

/*  */

/* Cheers to Cyber Nations Wiki for their permission to use this script and Bobogoobo from the Cyber Nations Wiki! and Green tentacle for their help with this! */

function setupUploadForm{ var wpLicense = document.getElementById('wpLicense'); var mwUploadTable = document.getElementById('mw-upload-table');

if ( wpLicense ){ if (window.location.search.indexOf('basic=true') == -1){ // Hack to get insertTags to work document.editform = document.getElementById('mw-upload-form');

// Bind upload button to verify function document.getElementById('mw-upload-form').onsubmit = verifySummary;

// Hide row for existing summary box var wpUploadDescription = document.getElementById('wpUploadDescription'); wpUploadDescription.parentNode.parentNode.style.display = 'none';

mwUploadTable.className = 'hidable start-hidden';

// Create new tbodies to allow for hideable bit var tbody1 = mwUploadTable.tBodies[0]; var tbody2 = document.createElement('tbody'); tbody2.className = 'hidable-content'; var tbody3 = document.createElement('tbody'); mwUploadTable.appendChild(tbody2); mwUploadTable.appendChild(tbody3);

// Move existing rows to the right tbody tbody3.appendChild(tbody1.rows[6]); tbody3.appendChild(tbody1.rows[6]); tbody3.appendChild(tbody1.rows[6]); tbody3.appendChild(tbody1.rows[6]);

var newRow, newRowLabel, newRowControl;

// Additional Licensing newRow = tbody1.insertRow(6); newRowLabel = newRow.insertCell(0); newRowControl = newRow.insertCell(1); newRowLabel.className = 'mw-label'; newRowLabel.style.width = '125px'; newRowControl.className = 'mw-input'; newRowLabel.innerHTML = ' Additional license information: '; newRowControl.innerHTML = ' ';

// Source newRow = tbody1.insertRow(7); newRowLabel = newRow.insertCell(0); newRowControl = newRow.insertCell(1); newRowLabel.className = 'mw-label'; newRowLabel.style.width = '125px'; newRowControl.className = 'mw-input'; newRowLabel.innerHTML = ' Source: (required) '; newRowControl.innerHTML = ' '; // Description newRow = tbody1.insertRow(8); newRowLabel = newRow.insertCell(0); newRowControl = newRow.insertCell(1); newRowLabel.className = 'mw-label'; newRowControl.className = 'mw-input'; newRowLabel.innerHTML = ' Description: (required) '; newRowControl.innerHTML = ' ';

// Date newRow = tbody2.insertRow(0); newRowLabel = newRow.insertCell(0); newRowControl = newRow.insertCell(1); newRowLabel.className = 'mw-label'; newRowControl.className = 'mw-input'; newRowLabel.innerHTML = ' Date: '; newRowControl.innerHTML = ' ';

// Author newRow = tbody2.insertRow(1); newRowLabel = newRow.insertCell(0); newRowControl = newRow.insertCell(1); newRowLabel.className = 'mw-label'; newRowControl.className = 'mw-input'; newRowLabel.innerHTML = ' Author: '; newRowControl.innerHTML = ' ';

// File specs newRow = tbody2.insertRow(2); newRowLabel = newRow.insertCell(0); newRowControl = newRow.insertCell(1); newRowLabel.className = 'mw-label'; newRowControl.className = 'mw-input'; newRowLabel.innerHTML = ' Conversion / editing / upload information: '; newRowControl.innerHTML = ' ';

// Other versions newRow = tbody2.insertRow(3); newRowLabel = newRow.insertCell(0); newRowControl = newRow.insertCell(1); newRowLabel.className = 'mw-label'; newRowControl.className = 'mw-input'; newRowLabel.innerHTML = ' Other versions: '; newRowControl.innerHTML = ' ';

// Notes newRow = tbody2.insertRow(4); newRowLabel = newRow.insertCell(0); newRowControl = newRow.insertCell(1); newRowLabel.className = 'mw-label'; newRowControl.className = 'mw-input'; newRowLabel.innerHTML = ' Notes: '; newRowControl.innerHTML = ' ';

// Categories newRow = tbody2.insertRow(5); newRowLabel = newRow.insertCell(0); newRowControl = newRow.insertCell(1); newRowLabel.className = 'mw-label'; newRowControl.className = 'mw-input'; newRowLabel.innerHTML = ' Categories : '; newRowControl.innerHTML = ' ';

} else { // Old style form just needs Information template in the summary box document.getElementById('wpUploadDescription').value = '==Summary==\r\n'; }	} }

function verifySummary{ var wpLicense = document.getElementById('wpLicense');

// Check for licensing 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 = '==Summary==\r\n';

document.getElementById('wpUploadDescription').value = strBuilder;

wpLicense.selectedIndex = 0;

return true; }

function loadFunc { setupUploadForm; }

$(loadFunc); /* */