Post by ialex on Oct 2, 2007 17:21:51 GMT -8
Whenever someone modifies their profile, this code will add an extra option, where the user is able to personally select whether they wish to participate in karma. If they select to Opt-Out, then there amount of Karma will be removed from both their main and mini profile, and no one will be able to exalt or smite them.
Preview: Click
Cross Browser.
Global Footer.
<script type="text/javascript">
<!--
/*Opt-Out of Karma - By iAlex - Open Source*/
if(document.modifyForm && document.modifyForm.showage){
var iPersonal=document.modifyForm.personaltext;
var iTable=document.modifyForm.showage.parentNode.parentNode.parentNode.parentNode.parentNode;
var iDiv=document.createElement('div');
iDiv.innerHTML='<table cellpadding="2" cellspacing="2" border="0" width="650px"><tr><td width="162px" valign="top"><font size="-1">Karma:</font></td><td width="245px"><font size="-1"><select id="iKarmaOpt"><option value="iIn">Opt-In</option><option value="iOut">Opt-Out</option></select></font></td><td width="245"><font size="-2">If you do not want others to have the ability to exalt/smite you, please opt out.</font></td></tr></table>';
iTable.parentNode.insertBefore(iDiv, iTable);
var iKarmaOpt=document.getElementById('iKarmaOpt');
if(iPersonal.value.match(/\[k4r\]/)){
iKarmaOpt.selectedIndex=1;
}
iPersonal.value=iPersonal.value.replace(/\[k4r\]/g, '');
if(document.addEventListener){
document.modifyForm.addEventListener('submit', function(){
if(iKarmaOpt.value=="iOut" && !iPersonal.value.match(/\[k4r\]/)){
iPersonal.value=iPersonal.value+'[k4r]';
}
}, false);
}
else{
document.modifyForm.attachEvent('onsubmit', function(){
if(iKarmaOpt.value=="iOut" && !iPersonal.value.match(/\[k4r\]/)){
iPersonal.value=iPersonal.value+'[k4r]';
}
});
}
}
if(location.href.match(/action=(display|viewprofile|(user)?recent|calendarview|search2|pmview|)/)){
var iTd=document.getElementsByTagName('td');
for(i=0;i<iTd.length;i++){
if(iTd.item(i).width=="20%" && iTd.item(i).vAlign=="top" && iTd.item(i).className.match(/windowbg(2)?/) && iTd.item(i).innerHTML.match(/member is/) && iTd.item(i).innerHTML.match(/\[k4r\]/)){
iTd.item(i).innerHTML=iTd.item(i).innerHTML.replace(/<br\s?\/?>Karma:\s(.+?)(<br\s?\/?>(.+?))?$/i, '').replace(/\[k4r\]/g, '');
}
if(location.href.match(/action=viewprofile/) && iTd.item(i).width=="25%" && iTd.item(i).innerHTML.match(/>Karma:</)){
iTd.item(i).parentNode.style.display='none';
}
}
}
//-->
</script>
Preview: Click
Cross Browser.
Global Footer.
<script type="text/javascript">
<!--
/*Opt-Out of Karma - By iAlex - Open Source*/
if(document.modifyForm && document.modifyForm.showage){
var iPersonal=document.modifyForm.personaltext;
var iTable=document.modifyForm.showage.parentNode.parentNode.parentNode.parentNode.parentNode;
var iDiv=document.createElement('div');
iDiv.innerHTML='<table cellpadding="2" cellspacing="2" border="0" width="650px"><tr><td width="162px" valign="top"><font size="-1">Karma:</font></td><td width="245px"><font size="-1"><select id="iKarmaOpt"><option value="iIn">Opt-In</option><option value="iOut">Opt-Out</option></select></font></td><td width="245"><font size="-2">If you do not want others to have the ability to exalt/smite you, please opt out.</font></td></tr></table>';
iTable.parentNode.insertBefore(iDiv, iTable);
var iKarmaOpt=document.getElementById('iKarmaOpt');
if(iPersonal.value.match(/\[k4r\]/)){
iKarmaOpt.selectedIndex=1;
}
iPersonal.value=iPersonal.value.replace(/\[k4r\]/g, '');
if(document.addEventListener){
document.modifyForm.addEventListener('submit', function(){
if(iKarmaOpt.value=="iOut" && !iPersonal.value.match(/\[k4r\]/)){
iPersonal.value=iPersonal.value+'[k4r]';
}
}, false);
}
else{
document.modifyForm.attachEvent('onsubmit', function(){
if(iKarmaOpt.value=="iOut" && !iPersonal.value.match(/\[k4r\]/)){
iPersonal.value=iPersonal.value+'[k4r]';
}
});
}
}
if(location.href.match(/action=(display|viewprofile|(user)?recent|calendarview|search2|pmview|)/)){
var iTd=document.getElementsByTagName('td');
for(i=0;i<iTd.length;i++){
if(iTd.item(i).width=="20%" && iTd.item(i).vAlign=="top" && iTd.item(i).className.match(/windowbg(2)?/) && iTd.item(i).innerHTML.match(/member is/) && iTd.item(i).innerHTML.match(/\[k4r\]/)){
iTd.item(i).innerHTML=iTd.item(i).innerHTML.replace(/<br\s?\/?>Karma:\s(.+?)(<br\s?\/?>(.+?))?$/i, '').replace(/\[k4r\]/g, '');
}
if(location.href.match(/action=viewprofile/) && iTd.item(i).width=="25%" && iTd.item(i).innerHTML.match(/>Karma:</)){
iTd.item(i).parentNode.style.display='none';
}
}
}
//-->
</script>