Failsafe YACCS

archives


Monday, April 01, 2002

 
Working hack, version 0.9.9:

Add defer="defer" to the script tag that calls YACCS, something like:


<script src="http://rateyourmusic.com/bc?b=90000009965" type="text/javascript" defer="defer"></script>


Add a chunk of script to the <head> section of your template, and change the variables at the top to what you want to have shown before and after the count for zero, one, and more than one comment, and for archived (older) comment counts:


<script type="text/javascript">
function countcomments(){
zero_pre = 'Comments ['
zero_suf = ']'
zero_show = 1
one_pre = 'Comments ['
one_suf = ']'
one_show = 1
many_pre = 'Comments ['
many_suf = ']'
many_show = 1
archived_text = 'archived'

if (document.childNodes)
{
if(typeof(ycsx) != "undefined")
{
for (i=0;i<ycsx.length/2;i++)
{
oSpan = document.getElementById("comment"+ycsx[i*2]);
if(oSpan)
{
oSpanText = oSpan.firstChild;
while(oSpanText.nodeType != "3")
{
if(oSpanText.hasChildNodes)
{
oSpanText = oSpanText.firstChild;
}
else
{
return false;
}
}
oSpanText.nodeValue = yaccs_fs_text(ycsx[i*2],zero_pre,zero_suf,zero_show,one_pre,one_suf,one_show,many_pre,many_suf,many_show,archived_text);
}
}
}
}
}
</script>


Add onload="countcomments();" to your body tag, something like:


<body onload="countcomments();">


Change your comment link (be sure to use your YACCS blog_id number, not mine!) to something like:


<a href="http://rateyourmusic.com/yaccs/comments?blog_id=90000009965&blog_entry_id=<$BlogItemNumber$>" onclick="window.open(this.href, '_blank', 'scrollbars=yes,resizable=yes,height=400,width=370,left=80,top=80'); return false;"><span id="comment<$BlogItemNumber$>">Add a comment</span></a>


Notes: the comment link works with or without Javascript, so you don't need a <noscript> link as well; the "Add a comment" text will be what actually shows for zero comments (with the possible exception of posts which had a comment which was later deleted), so you should change that to your "zero comments" text; on Blog*Spot, the ad will sometimes fail to load fully and prevent the body onload event from firing: either just click "Refresh" and it should work the second time, or think of it as a reason to pay for ad-free Blog*Spot.
posted by Phil Ringnalda 7:47 AM Add a comment


This page is powered by Blogger. Isn't yours?