|
Post by Wormopolis on Sept 30, 2010 0:03:48 GMT -8
Browser Tested: IE and FF placement: Global Footer
allows users to have a 2nd Avatar placed underneath their primary one. stores in Signature field.
<script type="text/javascript"> <!-- // 2nd avatar v1.1 // by Wormopolis - request by rhondairv // keep header intact
var onlyAllowedUsers=false; //set true if you want restriction var AV2_allowed="admin|user2|user3"; //seperate by |
// no need to edit below, unless you know what you are doing
if (document.modifyForm) { var av2rgx=new RegExp('^('+AV2_allowed+')$',''); whold=hhold=urlhold=''; if (modifyForm.signature.value.match(/\[av2:(.*?)x(.*?)\](.*?)\[\/av2\]/)) { whold=RegExp.$1; hhold=RegExp.$2; urlhold=RegExp.$3; modifyForm.signature.value=modifyForm.signature.value.replace(/\[av2:(.*?)x(.*?)\](.*?)\[\/av2\]/,''); }
if (!onlyAllowedUsers || pb_username.match(av2rgx)) { nwrw1=modifyForm.avatarurl.parentNode.parentNode.parentNode.cloneNode(true); nwrw2=modifyForm.avatarwidth.parentNode.parentNode.parentNode.cloneNode(true); nwrw3=modifyForm.avatarheight.parentNode.parentNode.parentNode.cloneNode(true); nwrw1.firstChild.firstChild.innerHTML="2nd " +nwrw1.firstChild.firstChild.innerHTML; nwrw2.firstChild.firstChild.innerHTML="2nd " +nwrw2.firstChild.firstChild.innerHTML; nwrw3.firstChild.firstChild.innerHTML="2nd " +nwrw3.firstChild.firstChild.innerHTML; nwrw1.firstChild.nextSibling.nextSibling.firstChild.innerHTML ="FOR THE SECOND AVATAR<br>" +nwrw1.firstChild.nextSibling.nextSibling.firstChild.innerHTML; nwrw1.firstChild.nextSibling.firstChild.firstChild.name= nwrw1.firstChild.nextSibling.firstChild.firstChild.id='avatarurl2'; nwrw2.firstChild.nextSibling.firstChild.firstChild.name= nwrw2.firstChild.nextSibling.firstChild.firstChild.id='avatarwidth2'; nwrw3.firstChild.nextSibling.firstChild.firstChild.name= nwrw3.firstChild.nextSibling.firstChild.firstChild.id='avatarheight2'; nwrw2.firstChild.nextSibling.firstChild.firstChild.value=whold; nwrw3.firstChild.nextSibling.firstChild.firstChild.value=hhold; nwrw1.firstChild.nextSibling.firstChild.firstChild.value=urlhold;
spot=modifyForm.avatarheight.parentNode.parentNode.parentNode; spot.parentNode.insertBefore(nwrw3, spot.nextSibling); spot.parentNode.insertBefore(nwrw2, spot.nextSibling); spot.parentNode.insertBefore(nwrw1, spot.nextSibling);
function addAv2() { if (modifyForm.avatarurl2.value) { nwstrng='[av2:'+modifyForm.avatarwidth2.value+'x'+ modifyForm.avatarheight2.value+']'+ modifyForm.avatarurl2.value+'[/av2]'; modifyForm.signature.value=nwstrng+modifyForm.signature.value; } }
if (document.modifyForm.addEventListener) { document.modifyForm.addEventListener('submit',addAv2,true); } else { document.modifyForm.attachEvent('onsubmit',addAv2); } } }
if (pb_action.match(/(display|viewprofile|search2)/i) || location.href.match(/action=display/)) { for (tds=document.getElementsByTagName('td'), chk=0; chk<tds.length; chk++) { if (tds[chk].width=='20%' && tds[chk].className.match(/windowbg/) && tds[chk].vAlign=='top' && tds[chk].nextSibling.innerHTML.match(/\[av2:(.*?)x(.*?)\](.*?)\[\/av2\]/)) { rwtmp=tds[chk].nextSibling.getElementsByTagName('font'); hitcell=rwtmp[rwtmp.length-1]; if (hitcell.innerHTML.match(/\[av2:(.*?)x(.*?)\](.*?)\[\/av2\]/)) { avholdurl=RegExp.$3; avholdwidth=RegExp.$1; avholdheight=RegExp.$2; hitcell.innerHTML=hitcell.innerHTML.replace(/\[av2:(.*?)x(.*?)\](.*?)\[\/av2\]/,''); plc=tds[chk].getElementsByTagName('center')[0].getElementsByTagName('br')[0]; newAv=document.createElement('img'); newAv.src=avholdurl; if (avholdwidth) newAv.width=avholdwidth; if (avholdheight) newAv.height=avholdheight; plc.parentNode.insertBefore(newAv, plc.nextSibling); plc.parentNode.insertBefore(document.createElement('br'), plc.nextSibling); } } } }
// --> </script>
|
|
|
Post by rhondairv on Oct 11, 2010 15:18:26 GMT -8
I am posting here because i can not find the request thread for it and search won't let me use ''2nd''. I think there is an issue with IE. The avatar goes to the side of the 1st avatar, and throws the mini profile all off. Works fine in FF.
|
|
|
Post by Wormopolis on Oct 11, 2010 18:40:00 GMT -8
replace
plc.parentNode.insertBefore(newAv, plc.nextSibling);
with
plc.parentNode.insertBefore(newAv, plc.nextSibling); plc.parentNode.insertBefore(document.createElement('br'), plc.nextSibling);
|
|
|
Post by rhondairv on Oct 11, 2010 18:49:00 GMT -8
all fixed!!!
|
|
|
Post by Wormopolis on Aug 14, 2011 2:21:32 GMT -8
version update 1.1: added in variable for user inclusion
|
|
sol9999
Not New Member
Posts: 18
sol9999 said 0 great things
|
Post by sol9999 on Feb 3, 2012 7:27:45 GMT -8
this is great! thnks a lot for this code
|
|
|
Post by Wormopolis on Feb 3, 2012 8:57:20 GMT -8
I appreciate that!
|
|