<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: CKEditor Word Count Plugin</title>
	<atom:link href="http://www.n7studios.co.uk/2010/03/01/ckeditor-word-count-plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.n7studios.co.uk/2010/03/01/ckeditor-word-count-plugin/</link>
	<description></description>
	<lastBuildDate>Thu, 26 Aug 2010 17:07:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Joe</title>
		<link>http://www.n7studios.co.uk/2010/03/01/ckeditor-word-count-plugin/comment-page-1/#comment-485</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Wed, 28 Apr 2010 15:33:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.n7studios.co.uk/?p=496#comment-485</guid>
		<description>Hi, I made a couple of changes to your script which I find improves performance when there are a large amount of words (600+) and also seems to help a bit with the &#039;few words out&#039; bug.  

The changes are to use a different technique for stripping html (use the browser itself) and to add a trim and a regex based split to the GetWordCount function.  Relevant parts included below:

 /**
    * Takes the given HTML data, replaces all its HTML tags with nothing, splits the result by spaces, 
    * and outputs the array length i.e. number of words.
    * 
    * @param string htmlData HTML Data
    * @return int Word Count
    */
    function GetWordCount(htmlData) {	     
        return strip(htmlData).trim().split(/\s+/).length;    
    }
	
function strip(html)
{
   var tmp = document.createElement(&quot;DIV&quot;);
   tmp.innerHTML = html;
   return tmp.textContent&#124;&#124;tmp.innerText;
}</description>
		<content:encoded><![CDATA[<p>Hi, I made a couple of changes to your script which I find improves performance when there are a large amount of words (600+) and also seems to help a bit with the &#8216;few words out&#8217; bug.  </p>
<p>The changes are to use a different technique for stripping html (use the browser itself) and to add a trim and a regex based split to the GetWordCount function.  Relevant parts included below:</p>
<p> /**<br />
    * Takes the given HTML data, replaces all its HTML tags with nothing, splits the result by spaces,<br />
    * and outputs the array length i.e. number of words.<br />
    *<br />
    * @param string htmlData HTML Data<br />
    * @return int Word Count<br />
    */<br />
    function GetWordCount(htmlData) {<br />
        return strip(htmlData).trim().split(/\s+/).length;<br />
    }</p>
<p>function strip(html)<br />
{<br />
   var tmp = document.createElement(&#8220;DIV&#8221;);<br />
   tmp.innerHTML = html;<br />
   return tmp.textContent||tmp.innerText;<br />
}
<div class="crfp-rating crfp-rating-0"></div>
]]></content:encoded>
	</item>
	<item>
		<title>By: jeremy</title>
		<link>http://www.n7studios.co.uk/2010/03/01/ckeditor-word-count-plugin/comment-page-1/#comment-425</link>
		<dc:creator>jeremy</dc:creator>
		<pubDate>Wed, 07 Apr 2010 00:51:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.n7studios.co.uk/?p=496#comment-425</guid>
		<description>Where do I put the HTMl for the CKEditor instance? I&#039;m using CKEditor with a Drupal module. Would it be different there?  Thanks for the help. And thanks for this plugin. Hope it works, because it could be very useful.  Thank You.  Jeremy</description>
		<content:encoded><![CDATA[<p>Where do I put the HTMl for the CKEditor instance? I&#8217;m using CKEditor with a Drupal module. Would it be different there?  Thanks for the help. And thanks for this plugin. Hope it works, because it could be very useful.  Thank You.  Jeremy
<div class="crfp-rating crfp-rating-0"></div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob Hunter</title>
		<link>http://www.n7studios.co.uk/2010/03/01/ckeditor-word-count-plugin/comment-page-1/#comment-407</link>
		<dc:creator>Rob Hunter</dc:creator>
		<pubDate>Wed, 31 Mar 2010 05:04:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.n7studios.co.uk/?p=496#comment-407</guid>
		<description>I had an issue with destroying CKEdtitor instances -- sometimes it would raise an error:
  i.contentWindow is null
which, corresponds to ckeditor/_source/core/dom/element.js:1331:
 return $ &amp;&amp; new CKEDITOR.dom.document( $.contentWindow.document );

It turned out to be triggered by the Word Count plugin&#039;s use of &quot;setTimeout&quot; and &quot;getData&quot;. The editor had been destroyed before the timeout triggered to run getData.

I hope this helps someone else!</description>
		<content:encoded><![CDATA[<p>I had an issue with destroying CKEdtitor instances &#8212; sometimes it would raise an error:<br />
  i.contentWindow is null<br />
which, corresponds to ckeditor/_source/core/dom/element.js:1331:<br />
 return $ &amp;&amp; new CKEDITOR.dom.document( $.contentWindow.document );</p>
<p>It turned out to be triggered by the Word Count plugin&#8217;s use of &#8220;setTimeout&#8221; and &#8220;getData&#8221;. The editor had been destroyed before the timeout triggered to run getData.</p>
<p>I hope this helps someone else!
<div class="crfp-rating crfp-rating-0"></div>
]]></content:encoded>
	</item>
</channel>
</rss>
