Post by CrAzY_J on Jan 5, 2006 18:44:01 GMT -8
Code description: With this code you can add extra message icons to the posting area, you can also set which users are allowed to use each message icon.
Code creator: CrAzY_J
Code Cross Browser check: Firefox 1.0 and Internet Explorer 6.0
Global Footers:
<script type='text/javascript'>
/* Add message icons V1
created by crAzY_J
Do not redistribute this code without the creator's permisson*/
var AddIcons = [
['name','image url',['user1','user2'] ],
['name','image',['user1','user2'] ],
['name','image',['all'] ],
['name','image',['all'] ]
];
var TD = document.body.getElementsByTagName('td');
if( document.postForm && document.postForm.icon && this.location.href.match(/post$/) )
{
function Addthis(event)
{
//IE being a bitch here >_>
if( !isNaN(parseInt( document.postForm.icon.options[ document.postForm.icon.selectedIndex ].value)) )
{
document.images.iconImage.src = AddIcons[ document.postForm.icon.options[ document.postForm.icon.options.selectedIndex ].value ][1];
return true;
}else
{
return false;
}
}
function Addanother(event)
{
if( !isNaN(parseInt( document.postForm.icon.options[ document.postForm.icon.selectedIndex ].value)) )
{
if( !document.postForm.subject.value.match(/&\^\d+\^&$/) )
document.postForm.subject.value += ' &^'+document.postForm.icon.options[ document.postForm.icon.selectedIndex ].value+'^&';
document.postForm.icon.selectedIndex = 0;
}
}
for( var a = 0 ; a < AddIcons.length ; a ++ )
{
for( var b = 0 ; b < AddIcons[2].length ; b ++ )
{
if( pb_username.match( new RegExp('^'+AddIcons[2]+'$','i') ) )
{
document.postForm.icon[ document.postForm.icon.options.length ] = new Option(AddIcons[0], a);
}else if( AddIcons[2] == 'all' )
{
document.postForm.icon[ document.postForm.icon.options.length ] = new Option(AddIcons[0], a);
}
}
}
if( document.postForm.icon.addEventListener )
{
document.postForm.addEventListener('submit',Addanother,false);
document.postForm.icon.addEventListener('change',Addthis,false);
}else
{
document.postForm.attachEvent('onsubmit',Addanother);
document.postForm.icon.attachEvent('onchange',Addthis);
}
}
if( this.location.href.match(/board=\w+(&\w+=\d)?$/) )
{
for( var t = 0 ; t < TD.length ; t ++ )
{
if( TD[t].className == 'windowbg' && TD[t].width == '48%' && TD[t].innerHTML.match(/&(amp;)?\^\d+\^&(amp;)?/) )
{
TD[t].innerHTML = TD[t].innerHTML.replace(/&(amp;)?\^(\d+)\^&(amp;)?/g,'');
TD[t-1].getElementsByTagName('img')[0].src = AddIcons[RegExp.$2][1];
}
}
}
if( document.title.match(/&\^\d+\^&/) )
{
document.title = document.title.replace(/&\^(\d+)\^&/,'');
for( var t = 0 ; t < TD.length ; t ++ )
{
if( TD[t].width == '5%' && TD[t].vAlign == 'middle' )
TD[t].firstChild.src = AddIcons[RegExp.$1][1];
}
}
if( !document.postForm )
{
for( var t = 0 ; t < TD.length ; t ++ )
{
if( TD[t].width == '100%' && TD[t].vAlign == 'top' )
TD[t].innerHTML = TD[t].innerHTML.replace(/&(amp;)?\^(\d+)\^&(amp;)?/g,'');
}
}
</script>
Code instructions:
As you can see, there is a line with a couple of colored words, and under that, exactly the same lines except they're not colored.
Those lines you have to edit. Each line is for a new icon. So for more icons you keep adding that line with the others:
['name','image url',['user1','user2'] ],
After each line that you have to edit, you see a comma, make sure ALL lines that you have to edit has a comma EXCEPT the last one.
Now for what you have to edit, the red is the name.
Orange is the url of the image.
And the blue parts are the usernames of the people who are allowed to use it. If you want to add more usernames just do it like this:
['user1','user2','user3','user4']
Each username in quotes and seperated by a comma.
If you want all users to be able to use the message icon, just use "all"
Enjoy
Code creator: CrAzY_J
Code Cross Browser check: Firefox 1.0 and Internet Explorer 6.0
Global Footers:
<script type='text/javascript'>
/* Add message icons V1
created by crAzY_J
Do not redistribute this code without the creator's permisson*/
var AddIcons = [
['name','image url',['user1','user2'] ],
['name','image',['user1','user2'] ],
['name','image',['all'] ],
['name','image',['all'] ]
];
var TD = document.body.getElementsByTagName('td');
if( document.postForm && document.postForm.icon && this.location.href.match(/post$/) )
{
function Addthis(event)
{
//IE being a bitch here >_>
if( !isNaN(parseInt( document.postForm.icon.options[ document.postForm.icon.selectedIndex ].value)) )
{
document.images.iconImage.src = AddIcons[ document.postForm.icon.options[ document.postForm.icon.options.selectedIndex ].value ][1];
return true;
}else
{
return false;
}
}
function Addanother(event)
{
if( !isNaN(parseInt( document.postForm.icon.options[ document.postForm.icon.selectedIndex ].value)) )
{
if( !document.postForm.subject.value.match(/&\^\d+\^&$/) )
document.postForm.subject.value += ' &^'+document.postForm.icon.options[ document.postForm.icon.selectedIndex ].value+'^&';
document.postForm.icon.selectedIndex = 0;
}
}
for( var a = 0 ; a < AddIcons.length ; a ++ )
{
for( var b = 0 ; b < AddIcons[2].length ; b ++ )
{
if( pb_username.match( new RegExp('^'+AddIcons[2]+'$','i') ) )
{
document.postForm.icon[ document.postForm.icon.options.length ] = new Option(AddIcons[0], a);
}else if( AddIcons[2] == 'all' )
{
document.postForm.icon[ document.postForm.icon.options.length ] = new Option(AddIcons[0], a);
}
}
}
if( document.postForm.icon.addEventListener )
{
document.postForm.addEventListener('submit',Addanother,false);
document.postForm.icon.addEventListener('change',Addthis,false);
}else
{
document.postForm.attachEvent('onsubmit',Addanother);
document.postForm.icon.attachEvent('onchange',Addthis);
}
}
if( this.location.href.match(/board=\w+(&\w+=\d)?$/) )
{
for( var t = 0 ; t < TD.length ; t ++ )
{
if( TD[t].className == 'windowbg' && TD[t].width == '48%' && TD[t].innerHTML.match(/&(amp;)?\^\d+\^&(amp;)?/) )
{
TD[t].innerHTML = TD[t].innerHTML.replace(/&(amp;)?\^(\d+)\^&(amp;)?/g,'');
TD[t-1].getElementsByTagName('img')[0].src = AddIcons[RegExp.$2][1];
}
}
}
if( document.title.match(/&\^\d+\^&/) )
{
document.title = document.title.replace(/&\^(\d+)\^&/,'');
for( var t = 0 ; t < TD.length ; t ++ )
{
if( TD[t].width == '5%' && TD[t].vAlign == 'middle' )
TD[t].firstChild.src = AddIcons[RegExp.$1][1];
}
}
if( !document.postForm )
{
for( var t = 0 ; t < TD.length ; t ++ )
{
if( TD[t].width == '100%' && TD[t].vAlign == 'top' )
TD[t].innerHTML = TD[t].innerHTML.replace(/&(amp;)?\^(\d+)\^&(amp;)?/g,'');
}
}
</script>
Code instructions:
As you can see, there is a line with a couple of colored words, and under that, exactly the same lines except they're not colored.
Those lines you have to edit. Each line is for a new icon. So for more icons you keep adding that line with the others:
['name','image url',['user1','user2'] ],
After each line that you have to edit, you see a comma, make sure ALL lines that you have to edit has a comma EXCEPT the last one.
Now for what you have to edit, the red is the name.
Orange is the url of the image.
And the blue parts are the usernames of the people who are allowed to use it. If you want to add more usernames just do it like this:
['user1','user2','user3','user4']
Each username in quotes and seperated by a comma.
If you want all users to be able to use the message icon, just use "all"
Enjoy