I started using the NedStatBasic web counters almost a week ago now. One of the problems, however, was that each time I went to my own weblog to check that it was posting correctly I incremented the stats.
To avoid this problem I needed to change the script not to run if I hit the web page. To do this I created a web page that would assign a cookie to me. The code was as follows:
<HTML> <BODY onload="document.cookie = 'IsWebLogAuthor = true; expires=Fri, 01-Jan-2010 00:00:01 GMT';"> </BODY> </HTML>
After hitting this page I had a cookie assigned. Not that an expiration date is required to make sure that the cookie survives across sessions.
Next, I added a postStatistics(id, options) function to my #homeTemplate.txt page within Radio as follows:
<!-- BEGIN_CUSTOM_EDIT --> <script> function postStatistics(id, options) { var isAuthor; var nameValue; var cookieArray = document.cookie.split(";"); for(var i=0; i<cookieArray.length; i++) { nameValue = cookieArray[i].split("="); if(nameValue.length==2 && nameValue[0]=="IsWebLogAuthor" && nameValue[1]=="true") { isAuthor=true; break; } } if(!isAuthor) { nedstatbasic(id, options); } } </script> <!-- END_CUSTOM_EDIT -->
Finally, in the NedStatBasic HTML source code I changed
<script language="JavaScript" type="text/javascript" > <!-- nedstatbasic("<my id>", 0); // --> </script>
to
<script language="JavaScript" type="text/javascript" > <!-- postStatistics("<my id>", 0); // --> </script>
There was also a <noscript> block but since my browser has scripting enabled this HTML never appears so I didn't need to worry about it.
One thing that puzzled me somewhat about this was the fact that the document.cookie was stored across documents on this site. In other words, setting the cookie on one page made it available to another page event though the cookie was a document property. Interesting.
I would like to thank Palani Thangaraj for help with this.
3:38:04 PM
|