Post by Virtuoso on Mar 22, 2008 19:58:56 GMT -5
Right, so add this to global footers:
<script type="text/javascript">
<!--
/* Extra Race option to Modify Profile page
Written by Virtuoso */
//Edit the following variables
var iName = "Race"; //Name (i.e. Race, Class, etc.)
var iVariables = ["Orc", "Elf", "Troll"]; //Add as many as you like
var iDes = "This is where you select which race you are." //The description you will see in the modify profile page.
//Do not edit past here
var iTABLE = document.getElementsByTagName('table');
var iCell = document.getElementsByTagName('td');
var iInput = document.createElement("option");
if(document.modifyForm)
{
for(t =0;t < iTABLE.length; t++)
{
if(iTABLE[t].width == "650" && iTABLE[t].cellSpacing == "2" && iTABLE[t].innerHTML.match(/gender/))
{
var iFrag = document.createDocumentFragment();
var iTR = document.createElement('tr');
var iTitle = document.createElement('td');
var iOption = document.createElement('td');
var iDescription = document.createElement('td');
var iSelect = document.createElement('select');
iTitle.setAttribute('colspan', '1');
iOption.setAttribute('colspan', '1');
iDescription.setAttribute('colspan', '1');
iSelect.name = 'race';
for(i = 0;i < iVariables.length; i ++)
{
iSelect.options = new Option(iVariables,iVariables)
}
iOption.appendChild(iSelect);
iTitle.appendChild(document.createTextNode(iName + ":"));
iDescription.appendChild(document.createTextNode(iDes));
iTR.appendChild(iTitle);
iTR.appendChild(iOption);
iTR.appendChild(iDescription);
iFrag.appendChild(iTR);
iTABLE[t].appendChild(iFrag);
}
}
function iSave()
{
var re = /:.+?)::/gi
if(document.modifyForm.signature.value.search(re) == -1){
document.modifyForm.signature.value+= "::" + document.modifyForm.race.options[document.modifyForm.race.selectedIndex].value + "::";
} else if(document.modifyForm.signature.value.search(re) != -1){
d ocument.modifyForm.signature.value = document.modifyForm.signature.value.replace(re, "::" + document.modifyForm.race.options[document.modifyForm.race.selectedIndex].value + "::");
}
}
if(document.addEventListener)
{
modifyForm.addEventListener('submit', iSave, false);
}else{
modifyForm.attachEvent('onsubmit', iSave);
}
}
if(this.location.href.match(/action=viewprofile/))
{
for(p = 0;p < iCell.length; p++){
if(iCell
.colSpan == "2" && iCell
.innerHTML.match(/:.+?)::/gi)){
var iSelectedRace = RegExp.$1;
iCell
.innerHTML = iCell
.innerHTML.replace(/:.+?)::/gi, "");
}
}
for(y = 0;y < iTABLE.length; y ++)
{
if(iTABLE[y].width == "100%" && iTABLE[y].cellSpacing == "1"){
iTABLE[y].getElementsByTagName('td')[1].innerHTML+= "<br/>";
iTABLE[y].getElementsByTagName('td')[1].innerHTML+= iName + ": ";
iTABLE[y].getElementsByTagName('td')[1].innerHTML+= iSelectedRace;
break;
}
}
}
if(document.modifyForm)
{
if(document.modifyForm.signature.value.match(/:.+?)::/gi)){
document.getElementsByName('race')[0].value = RegExp.$1;
}
}
//-->
</script>
And edit as necessary.