Working hack, version 0.9.9:
Adddefer="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>
Addonload="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
Working hack, version 0.9:
Adddefer="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 another big chunk of script to the <head> section of your template (this will get better once Hossein gives us a function in the remote script that we can call to get the link text):
<script type="text/javascript">
function failsafe_yaccs_linktext(count){
zero_pre = 'Comments ['
zero_suff = ']'
zero_show = 1
one_pre = 'Comments ['
one_suf = ']'
one_show = 1
many_pre = 'Comments ['
many_suf = ']'
many_show = 1
archived_text = 'archived'
prefix = ''
middle = ''
suffix = ''
if(count == -1)
{
prefix = archived_text
middle = ''
suffix = ''
}
else if(count == 0)
{
prefix = zero_pre
suffix = zero_suf
if(zero_show==1)
{
middle = count
}
}
else if (count==1)
{
prefix = one_pre
suffix = one_suf
if(one_show == 1)
{
middle=count
}
}
else
{
prefix = many_pre
suffix = many_suf
if(many_show==1)
{
middle = count
}
}
return prefix+middle+suffix
}
function countcomments(){
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 = failsafe_yaccs_linktext(ycsx[i*2+1]);
}
}
}
}
}
</script>
Addonload="countcomments();"
to your body tag, something like:
<body onload="countcomments();">
Change your comment link to:
<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>
To see what happens when the remote script fails to load, go to my yaccsfailtest example.
posted by Phil Ringnalda 9:19 AM Add a comment
Then, autoinstall YACCS (damn, that's cool stuff!).
posted by Phil Ringnalda 8:58 PM Add a comment
First, we need a post.
posted by Phil Ringnalda 8:53 PM Add a comment