Post by iAlex on Jan 12, 2008 2:11:57 GMT -5
This code will allow every user to input their Facebook ID when modifying their profile. A Facebook icon will then appear in their mini-profile.
This is the facebook icon that will be used, you may continue using it or change it via the URL at the top of the code:
Preview One: Click
Preview Two: Click
Cross Browser.
Global Footer.
Open Source.
<script type="text/javascript">
<!--
/*Facebook Icon in Mini Profile - By iAlex - Open Source*/
var iFaceIcon="http://img210.imageshack.us/img210/9975/ifacebookbn5.gif"; //Facebook mini profile icon
if(document.modifyForm){
var iAim=document.modifyForm.aim.parentNode.parentNode.parentNode;
var iFaceTr=iAim.cloneNode(true);
iFaceTr.childNodes[0].firstChild.innerHTML='Facebook:';
iFaceTr.childNodes[1].firstChild.innerHTML='<input type="text" size="35" maxlength="15" id="iFaceInp" />';
iFaceTr.childNodes[2].firstChild.innerHTML='Your Facebook id number here.';
iAim.parentNode.insertBefore(iFaceTr, iAim);
var iPerTe=document.modifyForm.personaltext;
var iFaceInp=document.getElementById('iFaceInp');
if(iPerTe.value.match(/\[F4:(.+?)\]/)){
iFaceInp.value=RegExp.$1;
iPerTe.value=iPerTe.value.replace(/\[F4:(.+?)\]/, '');
}
function iSaFa(){
if(iFaceInp.value!=""){
iPerTe.value=iPerTe.value+'[F4:'+iFaceInp.value+']';
}
}
if(document.addEventListener){
document.modifyForm.addEventListener('submit', iSaFa, false);
}
else{
document.modifyForm.attachEvent('onsubmit', iSaFa);
}
}
if(location.href.match(/action=(display|(user)?recent|viewprofile|calendarview|search2|pmview)/) || location.href.match(/index.cgi$/) && document.title.match(/Preview/) && document.postForm){
var iTd=document.getElementsByTagName('td');
var i=iTd.length;
while(--i){
if(iTd.item(i).width=="20%" && iTd.item(i).vAlign=="top" && iTd.item(i).className.match(/windowbg(2)?/) && iTd.item(i).innerHTML.match(/\[F4:(.+?)\]/)){
var iCentre=iTd.item(i).getElementsByTagName('center');
var iFaSpan=document.createElement('span');
iFaSpan.innerHTML='<a href="http://www.facebook.com/profile.php?id='+RegExp.$1+'" target="_blank"><img src="'+iFaceIcon+'" border="0" alt="Facebook" title="Facebook" /></a>';
iCentre.item(iCentre.length-1).appendChild(iFaSpan);
iTd.item(i).innerHTML=iTd.item(i).innerHTML.replace(/\[F4:(.+?)\]/, '');
}
}
}
//-->
</script>
This is the facebook icon that will be used, you may continue using it or change it via the URL at the top of the code:
Preview One: Click
Preview Two: Click
Cross Browser.
Global Footer.
Open Source.
<script type="text/javascript">
<!--
/*Facebook Icon in Mini Profile - By iAlex - Open Source*/
var iFaceIcon="http://img210.imageshack.us/img210/9975/ifacebookbn5.gif"; //Facebook mini profile icon
if(document.modifyForm){
var iAim=document.modifyForm.aim.parentNode.parentNode.parentNode;
var iFaceTr=iAim.cloneNode(true);
iFaceTr.childNodes[0].firstChild.innerHTML='Facebook:';
iFaceTr.childNodes[1].firstChild.innerHTML='<input type="text" size="35" maxlength="15" id="iFaceInp" />';
iFaceTr.childNodes[2].firstChild.innerHTML='Your Facebook id number here.';
iAim.parentNode.insertBefore(iFaceTr, iAim);
var iPerTe=document.modifyForm.personaltext;
var iFaceInp=document.getElementById('iFaceInp');
if(iPerTe.value.match(/\[F4:(.+?)\]/)){
iFaceInp.value=RegExp.$1;
iPerTe.value=iPerTe.value.replace(/\[F4:(.+?)\]/, '');
}
function iSaFa(){
if(iFaceInp.value!=""){
iPerTe.value=iPerTe.value+'[F4:'+iFaceInp.value+']';
}
}
if(document.addEventListener){
document.modifyForm.addEventListener('submit', iSaFa, false);
}
else{
document.modifyForm.attachEvent('onsubmit', iSaFa);
}
}
if(location.href.match(/action=(display|(user)?recent|viewprofile|calendarview|search2|pmview)/) || location.href.match(/index.cgi$/) && document.title.match(/Preview/) && document.postForm){
var iTd=document.getElementsByTagName('td');
var i=iTd.length;
while(--i){
if(iTd.item(i).width=="20%" && iTd.item(i).vAlign=="top" && iTd.item(i).className.match(/windowbg(2)?/) && iTd.item(i).innerHTML.match(/\[F4:(.+?)\]/)){
var iCentre=iTd.item(i).getElementsByTagName('center');
var iFaSpan=document.createElement('span');
iFaSpan.innerHTML='<a href="http://www.facebook.com/profile.php?id='+RegExp.$1+'" target="_blank"><img src="'+iFaceIcon+'" border="0" alt="Facebook" title="Facebook" /></a>';
iCentre.item(iCentre.length-1).appendChild(iFaSpan);
iTd.item(i).innerHTML=iTd.item(i).innerHTML.replace(/\[F4:(.+?)\]/, '');
}
}
}
//-->
</script>