We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Locked Topic
[ C ] Colour Names Across the Board
Topic Started: Sep 2 2012, 11:19 AM (477 Views)
RenaH-ZNR
Member Avatar
Member
[ *  * ]
Board Address: http://dbzf.co.uk
Board Software: ZetaBoards
Description: Currently using this code here: http://resources.zetaboards.com/topic/5066857/1/

What I would like is a similar code but without the bugs, when people are joining with a similar name to a member of staff, they end up with a coloured name as well, which they shouldn't do, the same as what's pointed out on that topic as a bug that topic titles get coloured.

I don't know if someone could make something similar without those problems, but I'd appreciate it, maybe looking for the userID in the URL, rather than picking up the name in the URL could work?

Thanks.
Offline Profile Goto Top
 
Pete B-ZNR
Member Avatar
Member
[ *  *  * ]
Only coded it so far to work on links. Not sure where a username might appear that isn't a link, but tell me if there is.

Code:
 
<script type="text/javascript">

$(function(){
function gcolors(uid, color) {
$("a[href*='/profile/']").each(function(){
url = $(this).attr('href');
uname = $(this).text();
uid_get = url.split('/profile/')[1].split('/')[0];
if(uid_get == uid){
$(this).html("<a href='"+url+"'><font color='"+color+"'>"+uname+"</font>");
}
});
}

//Specify users by ID here. Specify color afterwards.
gcolors(63280, "#000");
gcolors(1105853, "#FF0000");

});

</script>
Offline Profile Goto Top
 
RenaH-ZNR
Member Avatar
Member
[ *  * ]
Works well so far, the only other place I would like to see it is on the user profile page, such as here: http://dbzf.co.uk/profile/6932/

If you can add it so it colours the header name on there and in the navigation, I'd like that too, if that's not possible or would be too much work, then it's good as it is :)
Offline Profile Goto Top
 
Pete B-ZNR
Member Avatar
Member
[ *  *  * ]
No problem.

Code:
 
<script type="text/javascript">
$(function () {
function gcolors(uid, color) {
//Styles profile links
$("a[href*='/profile/']").each(function () {
url = $(this).attr('href');
uname = $(this).text();
uid_get = url.split('/profile/')[1].split('/')[0];
if (uid_get == uid) {
$(this).html("<a href='" + url + "'><font color='" + color + "'>" + uname + "</font>");
}
});
//Styles profile page text
if (window.location.href.indexOf("profile") > -1) {
path = window.location.pathname;
uid_cap = path.split('/profile/')[1].split('/')[0];
if (uid_cap == uid) {
username = $(".profile:first th:last").text();
$(".profile:first th:last").html("<font color='" + color + "'>" + username + "</font>");
$("#nav li:last").html("<span><font color='" + color + "'>" + username + "</font></span>");
}
}
}

//Specify users by ID here. Specify color afterwards.
gcolors(63280, "#FF0000");
gcolors(1105853, "#FF0000");

});
</script>
Offline Profile Goto Top
 
RenaH-ZNR
Member Avatar
Member
[ *  * ]
That's great, thanks :)
Offline Profile Goto Top
 
Pk Magic Hat
Member Avatar
Irritating requester
[ *  * ]
And a prefix/suffix image, is that possible to add through this code?
Offline Profile Goto Top
 
Pete B-ZNR
Member Avatar
Member
[ *  *  * ]
Mhmm

Prefix Image:
Spoiler: click to toggle


Suffix Image:

Spoiler: click to toggle
Offline Profile Goto Top
 
Pk Magic Hat
Member Avatar
Irritating requester
[ *  * ]
Looks very nice :) Thank you.

Edit: Woops! It removes the bold from the usernames! How can I fix that?
http://prntscr.com/ez6mz
Edited by Pk Magic Hat, Sep 4 2012, 01:34 PM.
Offline Profile Goto Top
 
Pete B-ZNR
Member Avatar
Member
[ *  *  * ]
Hmm.

Will carry over styles set in the ACP, but overwrite colours as defined.

No Image



Prepended Image


Appended Image

Edited by Pete B-ZNR, Sep 4 2012, 02:22 PM.
Offline Profile Goto Top
 
Pk Magic Hat
Member Avatar
Irritating requester
[ *  * ]
Thank you very much :)
Offline Profile Goto Top
 
Steve
Member Avatar
patriot
[ *  *  *  *  *  *  *  *  *  * ]
Completed!

Your request has been completed. If you have any questions or concerns regarding the state of your request, please feel free to contact me via PM.
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Closed Requests · Next Topic »
Locked Topic