User:Caesar Schinas/Pinkwich5.js

window.onload = function { if ((wgPageName.indexOf('/credit') != -1) && (wgAction == 'edit')) { var text = document.getElementById('wpTextbox1').value; if (text.indexOf('')).split('|'); var bodycontent = document.getElementById('bodycontent'); bodycontent.setAttribute('id','bodycontent-old'); bodycontent.style.display = 'none'; var div = document.createElement('div'); bodycontent.parentNode.appendChild(div); div.setAttribute('id','bodycontent'); div.innerHTML = "\ \n\ "; // set form field values if (args[0] && args[0] != 'licence') { document.getElementById('licence-other').value = args[0]; for (var value in Array('CC','GNU','PD','C')) { if (args[0].toUpperCase == value) { document.getElementById('licence').value = value; document.getElementById('licence-other').style.display = 'none'; }     }    } else { document.getElementById('licence').value = 'C'; document.getElementById('licence-other').style.display = 'none'; }   if (args[1] && args[1] != 'imagetype') { document.getElementById('imagetype-other').value = args[1]; for (var value in Array('Image','Photo','Diagram','Drawing','Painting','Artwork')) { if (args[1].toLowerCase == value.toLowerCase) { document.getElementById('imagetype').value = value; document.getElementById('imagetype-other').style.display = 'none'; }     }    } else { document.getElementById('imagetype').value = 'Image'; document.getElementById('imagetype-other').style.display = 'none'; }   if (args[2] && args[2] != 'author') document.getElementById('author').value = args[2]; // onchange handlers for selects document.getElementById('licence').onchange = function { if (document.getElementById('licence').value == 'other') document.getElementById('licence-other').style.display = 'inline'; else document.getElementById('licence-other').style.display = 'none'; }   document.getElementById('imagetype').onchange = function { if (document.getElementById('imagetype').value == 'other') document.getElementById('imagetype-other').style.display = 'inline'; else document.getElementById('imagetype-other').style.display = 'none'; }   // save the credit line document.getElementById('save').onclick = function { var value = ''; document.getElementById('wpTextbox1').value = value; document.getElementById('editform').submit; } } }