Post by ialex on Apr 28, 2008 17:04:57 GMT -8
This code will create a drop down menu in every user's profile under the account preferences. From this menu they will then be able to select where the mini profile will be displayed when browsing that board.
The options are: left of posts; right of posts; above posts; below posts; hidden.
Cross Browser.
Global Footer.
<script type="text/javascript">
<!--
/*Profile Selectable Mini Profile Location - By iAlex - Open Source*/
var iMini_Move={
iMini_Locate: function(){
if(document.modifyForm){
this.iProfile_Add();
}
if(window.location.href.match(/action=(display|(user)?recent|(calendar|pm)view)/) || window.location.href.match(/index.cgi$/) && document.title.match(/Preview/) && document.postForm || window.location.href.match(/index.cgi$/) && document.title.match(/\s-\sSearch\sResults/)){
this.iMini_Change();
}
},
iProfile_Add: function(){
var iSig_Tr=document.modifyForm.showsigs.parentNode.parentNode.parentNode;
var iNew_Tr=iSig_Tr.cloneNode(true);
iNew_Tr.firstChild.firstChild.replaceChild(document.createTextNode('Mini-Profile Location:'), iNew_Tr.firstChild.firstChild.firstChild);
iNew_Tr.firstChild.nextSibling.firstChild.innerHTML='<select id="iMini_Select"><option>Left of Posts</option><option>Right of Posts</option><option>Above Posts</option><option>Below Posts</option><option>Hidden</option></select>';
iNew_Tr.lastChild.firstChild.replaceChild(document.createTextNode('Here you will be able to select where you want the mini profile to be situated in correspondence with posts.'), iNew_Tr.lastChild.firstChild.firstChild);
iSig_Tr.parentNode.insertBefore(iNew_Tr, iSig_Tr);
var iMini_Select=document.getElementById('iMini_Select');
iMini_Select.selectedIndex=((document.cookie.match(/iMiniPosition=(\d+)/))? RegExp.$1 : 0);
function iSave_Mini(){
document.cookie='iMiniPosition='+iMini_Select.selectedIndex+';expires=Sat, 20 Jan 2050 12:12:12 UTC; path=/;';
}
if(document.addEventListener){
document.modifyForm.addEventListener('submit', iSave_Mini, false);
}
else{
document.modifyForm.attachEvent('onsubmit', iSave_Mini);
}
},
iMini_Change: function(){
var iMini_Num=(document.cookie.match(/iMiniPosition=(\d+)/))? parseInt(RegExp.$1) : 0;
if(iMini_Num!=0){
var iTd=document.getElementsByTagName('td');
var i=iTd.length-1;
do{
if(iTd.item(i).width=="20%" && iTd.item(i).vAlign=="top" && iTd.item(i).className.match(/windowbg(2)?/) && iTd.item(i).innerHTML.match(/<br\s?\/?>/i) && iTd.item(i).nextSibling && iTd.item(i).nextSibling.width=="80%" && iTd.item(i).nextSibling.height=="100%"){
var iTd_Next=iTd.item(i).nextSibling;
var iCentre=iTd.item(i).getElementsByTagName('center');
var iAvCentre=iCentre.item(iCentre.length-1);
switch(iMini_Num){
case 1:
(iTd.item(i).parentNode.previousSibling && iTd.item(i).parentNode.previousSibling.firstChild && iTd.item(i).parentNode.previousSibling.firstChild.nodeName.match(/^td$/i) && iTd.item(i).parentNode.previousSibling.firstChild.className=="catbg")? iTd.item(i).parentNode.previousSibling.insertBefore(iTd.item(i).parentNode.previousSibling.lastChild, iTd.item(i).parentNode.previousSibling.firstChild) : '';
iTd.item(i).parentNode.insertBefore(iTd_Next, iTd.item(i));
break;
case 2:
var iAvDiv=document.createElement('div');
if(iAvCentre.getElementsByTagName('img') && iAvCentre.getElementsByTagName('img').item(0) && iAvCentre.getElementsByTagName('img').item(0).alt=="[avatar]"){
iAvDiv.appendChild(iAvCentre.getElementsByTagName('img').item(0));
}
var iMini_Tr=document.createElement('tr');
iTd_Next.width='100%';
iTd_Next.colSpan='2';
iTd.item(i).width='100%';
iTd.item(i).colSpan='2';
iTd.item(i).innerHTML='<div style="float: left;">'+iAvDiv.innerHTML+'</div><div style="float: left; padding-left: 20px;">'+((iTd.item(i).innerHTML.match(/^(.+?)member is (.+?)<br\s?\/?>/im))? RegExp.$1+'member is '+RegExp.$2 : '')+'</div><div style="float: right;">'+((iTd.item(i).innerHTML.match(/Joined: (.+?)$/im))? 'Joined: '+RegExp.$1 : '')+'</div><div style="float: right; padding-right: 20px;">'+iAvCentre.innerHTML.replace(/^<br\s?\/?>(<br\s?\/?>)?(<br\s?\/?>)?(<br\s?\/?>)?/i, '')+'</div>';
iMini_Tr.appendChild(iTd.item(i));
iTd_Next.parentNode.parentNode.insertBefore(iMini_Tr, iTd_Next.parentNode);
break;
case 3:
var iAvDiv=document.createElement('div');
if(iAvCentre.getElementsByTagName('img') && iAvCentre.getElementsByTagName('img').item(0) && iAvCentre.getElementsByTagName('img').item(0).alt=="[avatar]"){
iAvDiv.appendChild(iAvCentre.getElementsByTagName('img').item(0));
}
var iMini_Tr=document.createElement('tr');
iTd_Next.width='100%';
iTd_Next.colSpan='2';
iTd.item(i).width='100%';
iTd.item(i).colSpan='2';
iTd.item(i).innerHTML='<div style="float: left;">'+iAvDiv.innerHTML+'</div><div style="float: left; padding-left: 20px;">'+((iTd.item(i).innerHTML.match(/^(.+?)member is (.+?)<br\s?\/?>/im))? RegExp.$1+'member is '+RegExp.$2 : '')+'</div><div style="float: right;">'+((iTd.item(i).innerHTML.match(/Joined: (.+?)$/im))? 'Joined: '+RegExp.$1 : '')+'</div><div style="float: right; padding-right: 20px;">'+iAvCentre.innerHTML.replace(/^<br\s?\/?>(<br\s?\/?>)?(<br\s?\/?>)?(<br\s?\/?>)?/i, '')+'</div>';
iMini_Tr.appendChild(iTd.item(i));
iTd_Next.parentNode.parentNode.insertBefore(iMini_Tr, iTd_Next.parentNode.nextSibling);
break;
case 4:
iTd.item(i).style.display='none';
iTd_Next.width='100%';
iTd_Next.colSpan='2';
break;
}
}
i--;
}
while(i>=6);
}
}
};
iMini_Move.iMini_Locate();
//-->
</script>
The options are: left of posts; right of posts; above posts; below posts; hidden.
Cross Browser.
Global Footer.
<script type="text/javascript">
<!--
/*Profile Selectable Mini Profile Location - By iAlex - Open Source*/
var iMini_Move={
iMini_Locate: function(){
if(document.modifyForm){
this.iProfile_Add();
}
if(window.location.href.match(/action=(display|(user)?recent|(calendar|pm)view)/) || window.location.href.match(/index.cgi$/) && document.title.match(/Preview/) && document.postForm || window.location.href.match(/index.cgi$/) && document.title.match(/\s-\sSearch\sResults/)){
this.iMini_Change();
}
},
iProfile_Add: function(){
var iSig_Tr=document.modifyForm.showsigs.parentNode.parentNode.parentNode;
var iNew_Tr=iSig_Tr.cloneNode(true);
iNew_Tr.firstChild.firstChild.replaceChild(document.createTextNode('Mini-Profile Location:'), iNew_Tr.firstChild.firstChild.firstChild);
iNew_Tr.firstChild.nextSibling.firstChild.innerHTML='<select id="iMini_Select"><option>Left of Posts</option><option>Right of Posts</option><option>Above Posts</option><option>Below Posts</option><option>Hidden</option></select>';
iNew_Tr.lastChild.firstChild.replaceChild(document.createTextNode('Here you will be able to select where you want the mini profile to be situated in correspondence with posts.'), iNew_Tr.lastChild.firstChild.firstChild);
iSig_Tr.parentNode.insertBefore(iNew_Tr, iSig_Tr);
var iMini_Select=document.getElementById('iMini_Select');
iMini_Select.selectedIndex=((document.cookie.match(/iMiniPosition=(\d+)/))? RegExp.$1 : 0);
function iSave_Mini(){
document.cookie='iMiniPosition='+iMini_Select.selectedIndex+';expires=Sat, 20 Jan 2050 12:12:12 UTC; path=/;';
}
if(document.addEventListener){
document.modifyForm.addEventListener('submit', iSave_Mini, false);
}
else{
document.modifyForm.attachEvent('onsubmit', iSave_Mini);
}
},
iMini_Change: function(){
var iMini_Num=(document.cookie.match(/iMiniPosition=(\d+)/))? parseInt(RegExp.$1) : 0;
if(iMini_Num!=0){
var iTd=document.getElementsByTagName('td');
var i=iTd.length-1;
do{
if(iTd.item(i).width=="20%" && iTd.item(i).vAlign=="top" && iTd.item(i).className.match(/windowbg(2)?/) && iTd.item(i).innerHTML.match(/<br\s?\/?>/i) && iTd.item(i).nextSibling && iTd.item(i).nextSibling.width=="80%" && iTd.item(i).nextSibling.height=="100%"){
var iTd_Next=iTd.item(i).nextSibling;
var iCentre=iTd.item(i).getElementsByTagName('center');
var iAvCentre=iCentre.item(iCentre.length-1);
switch(iMini_Num){
case 1:
(iTd.item(i).parentNode.previousSibling && iTd.item(i).parentNode.previousSibling.firstChild && iTd.item(i).parentNode.previousSibling.firstChild.nodeName.match(/^td$/i) && iTd.item(i).parentNode.previousSibling.firstChild.className=="catbg")? iTd.item(i).parentNode.previousSibling.insertBefore(iTd.item(i).parentNode.previousSibling.lastChild, iTd.item(i).parentNode.previousSibling.firstChild) : '';
iTd.item(i).parentNode.insertBefore(iTd_Next, iTd.item(i));
break;
case 2:
var iAvDiv=document.createElement('div');
if(iAvCentre.getElementsByTagName('img') && iAvCentre.getElementsByTagName('img').item(0) && iAvCentre.getElementsByTagName('img').item(0).alt=="[avatar]"){
iAvDiv.appendChild(iAvCentre.getElementsByTagName('img').item(0));
}
var iMini_Tr=document.createElement('tr');
iTd_Next.width='100%';
iTd_Next.colSpan='2';
iTd.item(i).width='100%';
iTd.item(i).colSpan='2';
iTd.item(i).innerHTML='<div style="float: left;">'+iAvDiv.innerHTML+'</div><div style="float: left; padding-left: 20px;">'+((iTd.item(i).innerHTML.match(/^(.+?)member is (.+?)<br\s?\/?>/im))? RegExp.$1+'member is '+RegExp.$2 : '')+'</div><div style="float: right;">'+((iTd.item(i).innerHTML.match(/Joined: (.+?)$/im))? 'Joined: '+RegExp.$1 : '')+'</div><div style="float: right; padding-right: 20px;">'+iAvCentre.innerHTML.replace(/^<br\s?\/?>(<br\s?\/?>)?(<br\s?\/?>)?(<br\s?\/?>)?/i, '')+'</div>';
iMini_Tr.appendChild(iTd.item(i));
iTd_Next.parentNode.parentNode.insertBefore(iMini_Tr, iTd_Next.parentNode);
break;
case 3:
var iAvDiv=document.createElement('div');
if(iAvCentre.getElementsByTagName('img') && iAvCentre.getElementsByTagName('img').item(0) && iAvCentre.getElementsByTagName('img').item(0).alt=="[avatar]"){
iAvDiv.appendChild(iAvCentre.getElementsByTagName('img').item(0));
}
var iMini_Tr=document.createElement('tr');
iTd_Next.width='100%';
iTd_Next.colSpan='2';
iTd.item(i).width='100%';
iTd.item(i).colSpan='2';
iTd.item(i).innerHTML='<div style="float: left;">'+iAvDiv.innerHTML+'</div><div style="float: left; padding-left: 20px;">'+((iTd.item(i).innerHTML.match(/^(.+?)member is (.+?)<br\s?\/?>/im))? RegExp.$1+'member is '+RegExp.$2 : '')+'</div><div style="float: right;">'+((iTd.item(i).innerHTML.match(/Joined: (.+?)$/im))? 'Joined: '+RegExp.$1 : '')+'</div><div style="float: right; padding-right: 20px;">'+iAvCentre.innerHTML.replace(/^<br\s?\/?>(<br\s?\/?>)?(<br\s?\/?>)?(<br\s?\/?>)?/i, '')+'</div>';
iMini_Tr.appendChild(iTd.item(i));
iTd_Next.parentNode.parentNode.insertBefore(iMini_Tr, iTd_Next.parentNode.nextSibling);
break;
case 4:
iTd.item(i).style.display='none';
iTd_Next.width='100%';
iTd_Next.colSpan='2';
break;
}
}
i--;
}
while(i>=6);
}
}
};
iMini_Move.iMini_Locate();
//-->
</script>