﻿<?xml version="1.0" encoding="utf-8"?>

<snippet name="Word Count bookmarklet" description="Word Count bookmarklet" preview="html" type="block">

<insertText location="beforeSelection">

<![CDATA[<a href="javascript:(function(){var t;if (window.getSelection) t = window.getSelection();else if (document.selection) t = document.selection.createRange();if (t.text != undefined) t = t.text;if(!t || t == &quot;&quot;){ a = document.getElementsByTagName(&quot;textarea&quot;); for(i=0; i<a.length; i++) {  if(a[i].selectionStart != undefined &amp;&amp; a[i].selectionStart != a[i].selectionEnd)  {    t = a[i].value.substring(a[i].selectionStart, a[i].selectionEnd);    break;  } }}if(!t || t == &quot;&quot;)alert(&quot;please select some text&quot;);else alert(&quot;word count: &quot; + t.toString().match(/(\S+)/g).length);})()">word count</a>



Select some text and click on word count]]>

</insertText>

<insertText location="afterSelection"><![CDATA[]]>

</insertText>

</snippet>

