Tuesday, July 31, 2012
Comment Counter Code Available!
Good morning! I'm so excited that my programmer husband, Tom, made the COMMENT COUNTER gadget now work with the updated blogger stuff. Yeah! Thanks, Tom! You guys are welcome to copy and paste the code below as an HTML gadget to your Layout if you would like your comments to be numbered.
IMPORTANT: You MUST choose the EMBEDDED option in SETTINGS for COMMENTS. This numbering system will NOT work with pop-up comments.
Find step-by-step photos below. :)
ENJOY! This code is FREE if you'd like to use it. :)
<style type="text/css">
.commentNumber {
border: 0px solid Black;
padding-right:5px;
display: inline;
color: #6FA8DC;
font-weight: bold;
}
</style>
<script type="text/javascript">
function getElementsByClassName2(className, tag, elm){
var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)");
var tag = tag || "*";
var elm = elm || document;
var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
var returnElements = [];
var current;
var length = elements.length;
for(var i=0; i<length; i++){
current = elements[i];
if(testClass.test(current.className)){
returnElements.push(current);
}
}
return returnElements;
}
function addCounters()
{
var numBox, i, j;
var topComments = getElementsByClassName2("comment-thread")[0].firstChild.children;
for (i = 0, j = topComments.length; i < j; i++)
{
var commentBlock = getElementsByClassName2("comment-block", "*", topComments[i])[0];
numBox = document.createElement("span");
numBox.className = "commentNumber";
numBox.appendChild(document.createTextNode((i + 1) + ':'));
commentBlock .firstChild.insertBefore(numBox, commentBlock .firstChild.firstChild);
}
}
addCounters();
</script>
If you want to see what this looks like in use... as soon as someone leaves me at least 1 comment on this post, it will start the numbering. Just click on my BLOG TITLE so that this post and it's comments are the only thing showing on the page. You'll see the comments numbered. I just love that he did this for me and all my friends. Sure does make it easier when doing a give-away and using random.org to pick a winner and not having to count the comments.
Have a GREAT day!
:) Janis
Click on photos to enlarge for better viewing.