Post by Todge on Jun 21, 2012 10:23:46 GMT -8
This script should give your members the option to set a background color to their posts.
Put it in your Global Footer, and you should see a new option in your profile form. No editing is required.
<script type="text/javascript">
<!--
/*
Member selected post colors..
by Todge
Copyright © 2012
Please keep this header intact
*/
// Add Post bgcolor option to profile..
if(document.modifyForm)
{
function addbgColor()
{
var bgc = document.getElementById('postbg').value;
if(bgc.match(/[a-fA-F\d]{6}/))
{
bgc = '[#'+bgc+']';
document.modifyForm.location.value = bgc+document.modifyForm.location.value;
}
else
{
alert('The post BG Color you have chosen ('+bgc+') is not a valid hexidecimal number, and has not been added.')
}
return;
}
var loc = document.modifyForm.location;
var age = document.modifyForm.showage.parentNode.parentNode.parentNode;
var postBG = '';
if(loc.value.match(/\[#[a-fA-F\d]{6}\]/))
{
var postBG = loc.value.split('[#')[1].split(']')[0];
loc.value = loc.value.replace('[#'+postBG+']','');
}
var tr = document.createElement('tr');
var td1 = document.createElement('td');
var td2 = document.createElement('td');
var td3 = document.createElement('td');
td1.innerHTML = '<font size="-1">Post Background Color:</font>';
td3.innerHTML = '<font size="-2">Use a 6 digit hex value to choose the background color of your posts.</font>';
var bgcol = document.createElement('input');
with(bgcol){ type="text"; maxLength="6"; value=postBG; id="postbg"; size="35"; }
td2.appendChild(bgcol);
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
age.parentNode.insertBefore(tr,age);
if(window.addEventListener)
{
document.modifyForm.addEventListener('submit', addbgColor, false);
}
else if(window.attachEvent)
{
document.modifyForm.attachEvent('onsubmit', addbgColor);
}}
// Remove hex value from mini-profiles and add postBG color..
if(pb_action.match(/(display|viewprofile|search2|pmview|previewpost)/))
{
var gColors = new Array();
var mp = document.getElementsByTagName('td');
for(m=0; m<mp.length; m++)
{
if(mp[m].width == '20%' && mp[m].className.match(/windowbg/) && mp[m].innerHTML.match(/Location: \[#[a-fA-F\d]{6}\]/))
{
var pColor = mp[m].innerHTML.split('Location: [')[1].split(']')[0];
mp[m].innerHTML = mp[m].innerHTML.replace('Location: ['+pColor+']','Location: ').replace(/Location: <br>/i,'');
if(pb_action == 'viewprofile')
{
var font = mp[m].nextSibling.getElementsByTagName('font');
for(f=1; f<font.length; f++)
{
if(font[f].innerHTML.match(/\[#[a-fA-F\d]{6}\]/))
{
if(font[f].innerHTML.length == 9)
{
font[f].parentNode.parentNode.style.display = 'none';
}
else
{
font[f].innerHTML = font[f].innerHTML.replace(/\[#[a-fA-F\d]{6}\]/,'');
}}}}
var pTD = mp[m].nextSibling.getElementsByTagName('td');
mp[m].nextSibling.style.backgroundColor = pColor;
for(p=0; p<pTD.length; p++)
{
if(pTD
Put it in your Global Footer, and you should see a new option in your profile form. No editing is required.
<script type="text/javascript">
<!--
/*
Member selected post colors..
by Todge
Copyright © 2012
Please keep this header intact
*/
// Add Post bgcolor option to profile..
if(document.modifyForm)
{
function addbgColor()
{
var bgc = document.getElementById('postbg').value;
if(bgc.match(/[a-fA-F\d]{6}/))
{
bgc = '[#'+bgc+']';
document.modifyForm.location.value = bgc+document.modifyForm.location.value;
}
else
{
alert('The post BG Color you have chosen ('+bgc+') is not a valid hexidecimal number, and has not been added.')
}
return;
}
var loc = document.modifyForm.location;
var age = document.modifyForm.showage.parentNode.parentNode.parentNode;
var postBG = '';
if(loc.value.match(/\[#[a-fA-F\d]{6}\]/))
{
var postBG = loc.value.split('[#')[1].split(']')[0];
loc.value = loc.value.replace('[#'+postBG+']','');
}
var tr = document.createElement('tr');
var td1 = document.createElement('td');
var td2 = document.createElement('td');
var td3 = document.createElement('td');
td1.innerHTML = '<font size="-1">Post Background Color:</font>';
td3.innerHTML = '<font size="-2">Use a 6 digit hex value to choose the background color of your posts.</font>';
var bgcol = document.createElement('input');
with(bgcol){ type="text"; maxLength="6"; value=postBG; id="postbg"; size="35"; }
td2.appendChild(bgcol);
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
age.parentNode.insertBefore(tr,age);
if(window.addEventListener)
{
document.modifyForm.addEventListener('submit', addbgColor, false);
}
else if(window.attachEvent)
{
document.modifyForm.attachEvent('onsubmit', addbgColor);
}}
// Remove hex value from mini-profiles and add postBG color..
if(pb_action.match(/(display|viewprofile|search2|pmview|previewpost)/))
{
var gColors = new Array();
var mp = document.getElementsByTagName('td');
for(m=0; m<mp.length; m++)
{
if(mp[m].width == '20%' && mp[m].className.match(/windowbg/) && mp[m].innerHTML.match(/Location: \[#[a-fA-F\d]{6}\]/))
{
var pColor = mp[m].innerHTML.split('Location: [')[1].split(']')[0];
mp[m].innerHTML = mp[m].innerHTML.replace('Location: ['+pColor+']','Location: ').replace(/Location: <br>/i,'');
if(pb_action == 'viewprofile')
{
var font = mp[m].nextSibling.getElementsByTagName('font');
for(f=1; f<font.length; f++)
{
if(font[f].innerHTML.match(/\[#[a-fA-F\d]{6}\]/))
{
if(font[f].innerHTML.length == 9)
{
font[f].parentNode.parentNode.style.display = 'none';
}
else
{
font[f].innerHTML = font[f].innerHTML.replace(/\[#[a-fA-F\d]{6}\]/,'');
}}}}
var pTD = mp[m].nextSibling.getElementsByTagName('td');
mp[m].nextSibling.style.backgroundColor = pColor;
for(p=0; p<pTD.length; p++)
{
if(pTD
.className.match(/windowbg/) || (!pTD
.className && !pTD
.firstChild.className.match(/(quote|code)/)))
{
pTD
.style.backgroundColor = pColor;
}}}}}
// -->
</script>