Pages

Friday, April 6, 2012

1

Small update for recent comments gadgets

I have updated the source code of all three recent comments gadgets today.

1. Bug fix

The gadget choked with comments on blog pages (versus articles). Fix for that was easy, search for line:

postTitle = hrefPost.split("/")[5].split(".html")[0].replace(/_\d{2}$/, "");

and change it to:

if(hrefPost.match(/\/([^/]*)\.html/)) postTitle = hrefPost.match(/\/([^/]*)\.html/)[1].replace(/_\d{2}$/, "");

That line is line number 88 in recent comments gadget, line 138 in return of recent comments gadget, and line number 141 in son of recent comments gadget.

2. Default/empty post title

I also updated this line (line number 85/135/138):

var postTitle="";

to this:

var postTitle="-";

So at least something is displayed, if title cannot be parsed.

3. Better linking to post page comments

In return of, and son of recent comments gadged, I also added this line:

if(!/#/.test(href)) href += "#comments";

It is line 185 in "return of", and line 192 in "son of". With a comment on a page this gets us positioned on top of the comments (versus top of the article). I did not make this update on the oldest gadget, if you're still using it, I suggest you try the latest version, son of the recent comments gadget.

I've updated the source code in the blog articles, you can look up the changes there.
Related Posts Plugin for WordPress, Blogger...
See the hack
for this dynamic
views icon: