HaloScan Commenting and Trackback

bodargetcam
vieltpa
cnaletovib

Handling HaloScan downtime gracefully


NOTE: this applies to the old version of Blogger only. The following does not apply for the new version of Blogger


If you are not comfortable editing your template and working with HTML code please do not proceed. The code provided is used at your discretion and is not a formal part of the HaloScan offering

Like any web service, HaloScan may not always be able to communicate with your site. Should a short period of downtime occur you can temporarily display a friendly message and allow your site to load as normal by adding some javascript to your site. The code will detect when the HaloScan service isn't available and stop error messages appearing.

Complete downtime is rare (at time of writing) and you may find re-loading your site is enough to load HaloScan.

Note: The following code will overwrite the comment link text you have specified in the Settings page.

In the following instructions be sure to check that HALOSCANUSERNAME is your actual HaloScan username. If you are unsure, please refer to the installation instructions.

To implement this code:
  1. Backup your site template.
  2. Edit your site template, locating the following code:
<script type="text/javascript" src="http://www.haloscan.com/load/HALOSCANUSERNAME"></script>

  1. Copy and paste the following BEFORE the code above.

<script type="text/javascript">
/* Extra HaloScan failsafe stuff */
  var hs   = new Array;
  var hstb = new Array;
  var hsc  = new Array;

  function HaloScanCount(id, type)
  {
   if (type=="trackback") hsc = hstb;
   else                   hsc = hs;

   if(hsc[id])
   {
    document.write(hsc[id] + " ");
   }
   else
   {
    document.write("No ");
   }
  }

  function HaloScanPlural(id, type)
  {
   if (type=="trackback") hsc = hstb;
   else                   hsc = hs;
 
   if(hsc[id] != 1)
   {
    document.write("s");
   }
  }
 </script>

  1. Locate the comment link code, further down your template, it will look something like this:
<a href="javascript:HaloScan('<$BlogItemNumber$>');" target="_self" class="haloscan"><script type="text/javascript">postCount('<$BlogItemNumber$>'); </script></a> | <a href="javascript:HaloScanTB('<$BlogItemNumber$>');" target="_self" class="haloscan"><script type="text/javascript">postCountTB('<$BlogItemNumber$>'); </script></a>

  1. Replace the code above, with the code below.
<nobr><a href="http://www.haloscan.com/comments/HALOSCANUSERNAME/<$BlogItemNumber$>" onclick="HaloScan('<$BlogItemNumber$>');return false;" class="haloscan"><script type="text/javascript">HaloScanCount('<$BlogItemNumber$>', 'comment');</script>Comment<script type="text/javascript">HaloScanPlural('<$BlogItemNumber$>', 'comment');</script></a></nobr> |
<nobr><a href="http://www.haloscan.com/tb/HALOSCANUSERNAME/<$BlogItemNumber$>
" onclick="HaloScanTB('<$BlogItemNumber$>');return false;" class="haloscan"><script type="text/javascript">HaloScanCount('<$BlogItemNumber$>', 'trackback');</script>Trackback<script type="text/javascript">HaloScanPlural('<$BlogItemNumber$>', 'trackback');</script></a></nobr>

  1. Save your template and republish your blog.

The code will produce the following comment and trackback links:
  • No Comments, 1 Comment, x Comments
  • No Trackbacks, 1 Trackback, x Trackbacks

and if Javascript is disabled the comment and trackback links will read as:
  • Comment
  • Trackback


Taken from the forums
Page was generated in 0.3365 seconds