Post by Xargo on Feb 14, 2006 10:06:08 GMT -8
Name: Private topic icons, optional icon namechange
Cross browser: Internet Explorer, Firefox, Netscape and Opera
Place: Global footer
Description: You can restrict certain topic icons to certain usernames and optionally change the names of the topic icons. For example if you want to make a special administrator topic icon that defines important topics first costumize an icon to your new image (eg. Change the lamp icon. New icons added with another script also work.) and then use my script to make it only available for the admin user and change the name to, "Admin icon".
A user that isn't allowed to use that icon will simply not see it in the list.
I will maybe add a visual example later.
Edit: I heavily recommend to use this together with a topic icon adding script, and only make the extra added topic icons private, otherwise every person with Javascript disabled will still be able to use the private icons.
Code explanation:
Brown -> The current name of the topic icon in the list of icons.
Blue -> The new name you want to give to the icon, if you want to keep it the same fill in the normal name then.
Purple -> The usernames that are allowed to use the icon. Notice these are the usernames, not the display names.
Code:
<script>
/* Restrict topic icons and optionally change their name :: by Xargo */
var rIcons= [
//["Current name", "New Name", ["user1", "user2"]], (You can add more than two users.)
["Lamp", "New Icon 1", ["admin","xargo"]],
["Laugh","New Icon 2", ["admin","xargo"]] //No comma behind the last one!
];
if (document.postForm && document.postForm.icon && (this.location.href.match(/post$/) || this.location.href.match(/modifypost/) || this.location.href.match(/post&thread=/)))
{
for (var a=0; a<rIcons.length; a++ )
{
for (var b=0; b<rIcons[2].length; b++ )
{
if (pb_username.match(new RegExp("^"+rIcons[2]+"$","i")))
{
var total = document.postForm.icon.options.length-1;
var items = new Array;
var values = new Array;
for (i = total; i >= 0; i--)
{
items = document.postForm.icon.options.text;
values = document.postForm.icon.options.value;
}
for (i = total; i >= 0; i--)
{
if (document.postForm.icon.options.text == rIcons[0])
{
document.postForm.icon.options.text = rIcons[1];
}
}
break;
}
else if (b == rIcons[2].length-1)
{
var total = document.postForm.icon.options.length-1;
var items = new Array;
var values = new Array;
for (i = total; i >= 0; i--)
{
items = document.postForm.icon.options.text;
values = document.postForm.icon.options.value;
}
for (i = total; i >= 0; i--)
{
if (document.postForm.icon.options.text == rIcons[0])
{
document.postForm.icon.options = null;
}
}
}
}
}
}
</script>
Cross browser: Internet Explorer, Firefox, Netscape and Opera
Place: Global footer
Description: You can restrict certain topic icons to certain usernames and optionally change the names of the topic icons. For example if you want to make a special administrator topic icon that defines important topics first costumize an icon to your new image (eg. Change the lamp icon. New icons added with another script also work.) and then use my script to make it only available for the admin user and change the name to, "Admin icon".
A user that isn't allowed to use that icon will simply not see it in the list.
I will maybe add a visual example later.
Edit: I heavily recommend to use this together with a topic icon adding script, and only make the extra added topic icons private, otherwise every person with Javascript disabled will still be able to use the private icons.
Code explanation:
Brown -> The current name of the topic icon in the list of icons.
Blue -> The new name you want to give to the icon, if you want to keep it the same fill in the normal name then.
Purple -> The usernames that are allowed to use the icon. Notice these are the usernames, not the display names.
Code:
<script>
/* Restrict topic icons and optionally change their name :: by Xargo */
var rIcons= [
//["Current name", "New Name", ["user1", "user2"]], (You can add more than two users.)
["Lamp", "New Icon 1", ["admin","xargo"]],
["Laugh","New Icon 2", ["admin","xargo"]] //No comma behind the last one!
];
if (document.postForm && document.postForm.icon && (this.location.href.match(/post$/) || this.location.href.match(/modifypost/) || this.location.href.match(/post&thread=/)))
{
for (var a=0; a<rIcons.length; a++ )
{
for (var b=0; b<rIcons[2].length; b++ )
{
if (pb_username.match(new RegExp("^"+rIcons[2]+"$","i")))
{
var total = document.postForm.icon.options.length-1;
var items = new Array;
var values = new Array;
for (i = total; i >= 0; i--)
{
items = document.postForm.icon.options.text;
values = document.postForm.icon.options.value;
}
for (i = total; i >= 0; i--)
{
if (document.postForm.icon.options.text == rIcons[0])
{
document.postForm.icon.options.text = rIcons[1];
}
}
break;
}
else if (b == rIcons[2].length-1)
{
var total = document.postForm.icon.options.length-1;
var items = new Array;
var values = new Array;
for (i = total; i >= 0; i--)
{
items = document.postForm.icon.options.text;
values = document.postForm.icon.options.value;
}
for (i = total; i >= 0; i--)
{
if (document.postForm.icon.options.text == rIcons[0])
{
document.postForm.icon.options = null;
}
}
}
}
}
}
</script>