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.







Script configuration



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: ).



cropAvatar: crop avatar to square (true) or stretch (false) to square

sizeAvatar: size of avatar in x and y direction, pixels



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;}



August 1st 2017: To fix avatars, please change lines 48 and 49 (article code is updated).