MediaWiki:Upload.js

/*  */

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

if (wpLicense) {   if (window.location.search.indexOf('basic=true') == -1) {     // 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;

// Source 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 = ' Source: '; newRowControl.innerHTML = ' '; // Description newRow = tbody1.insertRow(7); newRowLabel = newRow.insertCell(0); newRowControl = newRow.insertCell(1); newRowLabel.className = 'mw-label'; newRowControl.className = 'mw-input'; newRowLabel.innerHTML = ' Description: '; newRowControl.innerHTML = ' ';

// Show/hide optional fields newRow = tbody1.insertRow(8); newRowLabel = newRow.insertCell(0); newRowLabel.colSpan = '2'; newRowLabel.style.textAlign = 'center'; newRowLabel.innerHTML = 'Optional fields ';

// Attention newRow = tbody2.insertRow(0); newRowLabel = newRow.insertCell(0); newRowControl = newRow.insertCell(1); newRowLabel.className = 'mw-label'; newRowControl.className = 'mw-input'; newRowLabel.innerHTML = ' Attention: '; 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 = ' Original designer / artist: '; 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 = ' ';

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

// Licensee cat newRow = tbody2.insertRow(5); newRowLabel = newRow.insertCell(0); newRowControl = newRow.insertCell(1); newRowLabel.className = 'mw-label'; newRowControl.className = 'mw-input'; newRowLabel.innerHTML = ' Licensee 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; }

var strBuilder = '==Summary==\r\n';

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

wpLicense.selectedIndex = 0;

return true; }

/* */