Pages

Wednesday, May 2, 2012

Top Commentators Gadget with avatars

I had a request of this gadget in one blog comment. There are some top commentators gadgets around, most relying on a Yahoo pipe. I knew it can be done with just javascript, with no pipes. Demo: it is installed on this blog, look at the right sidebar. Hope you like it. :)

Features

You can configure the maximum number of top commentators, and minimum number of comments one must have to get on the list (to weed out the 1 comment commentators, if wanted, for example). Own nick and a list of other nicks (for example "Anonymous") can be excluded from the list. Output strings can be translated.

The Script, installing

Add a HTML/Javascript gadget to your blog, and paste the following code into it.

There are two CSS definitions at first, which can be changed to your liking. After that there comes javascript code and configurable variables. Here is a list of the variables and a short explanation.

maxTopCommenters: how big the list is at maximum
minComments: how many comments must top commentator have at least
numDays: from how many days (ex. 30), or 0 from "all the time" (max 500 comments)
excludeMe: true, if own comments excluded
excludeUsers: array of usernames to exclude
maxUserNameLength: if 0, don't cut; if > 4, cut lenghty usernames

txtTopLine: specifies, what is output on each line. This text can have simple variables, which are: [#], [image], [user], and [count]. [#] is substituted by position on the list, [image] by commentator's avatar image, [user] by commentator name and [count] by number of comments. Text can also contain html.
txtNoTopCommenters: what to display, if list is empty
txtAnonymous: "Anonymous" username localized, or empty if English text "Anonymous" is to be used
getTitles: if true, fetch titles from post feed; if false, titles are generated from url
blogger favico [B]
urlMyAvatar: especially if trueAvatars = false, set here the url to your avatar image
urlMyProfile: if you don't have a profile gadget on page, put your profile url here!
urlAnoAvatar: anonymous avatar, you can change from mystery man to a custom one, if you want, possibly this
urlNoAvatar: comment feed offers the icon (Blogger logo) for those Bloggers who have not set their profile image. You can override the icon with this setting (default: ).

If you have very much comments (thousands and thousands of them), I suggest you to use this as "top commentators of 30 days" gadget or something like that (set numDays variable to 30), so that it won't take too long to load and calculate all the comments.

June 5th 2012: Small CSS update: Blogger changed the paddings of .profile-name-link, that's why I added this line (line 3.):
.top-commenter-line .profile-name-link {padding-left:0;}

Thks for your prompt response! I should've included my link for your reference earlier! I'm not sure what's Profile Gadget but I think I've got one. I'm not tech savvy. Could u kindly take a look at my blog? If I don't have one, do I just copy & paste this "http://www.blogger.com/profile/04765892937555860461" inside the code? Thks so much!

Hey, the first method didn't work but the 2nd one works like magic. Chk it out! Thks so much! How can I exclude 2 names? Tried putting punctuation but didn't work. Lol! Pls advise! You've been a great help!

Thks a million! It's working :) U're a genius! Actually, I've been directed by Aratina Cage's blog at Last Comments. I was searching for solution to the Recent Comments which I've installed previously. It worked fine until lately, my comments are showing. Wonder if you can help? I only want to show visitors comments but not mine. Thks again!

I just installed this and I think mine needs some tweaking because I have no avatars or clickable links to my followers. Can you help?http://www.everydayunderwear.comI can be reached at hiyacynthia@hotmail.com for going back and forth.

Hey, I'm a brazilian blogger and I just came to say Thank you for create this code, it has transformed the way we can interact with our followers. :)So that's it. I'm really glad to know that r people like u in the world.Sorry for my bad english and thank u, one more time.xoxo, Nanda.If you feel like you want you, visit my blog: Nandalandia :D