[wp-trac] [WordPress Trac] #12921: Improve word count (was: Word count does not change until you hit enter)

WordPress Trac wp-trac at lists.automattic.com
Thu Apr 22 17:33:20 UTC 2010


#12921: Improve word count
-------------------------+--------------------------------------------------
 Reporter:  shdus        |        Owner:            
     Type:  enhancement  |       Status:  reopened  
 Priority:  normal       |    Milestone:  Unassigned
Component:  Editor       |      Version:  3.0       
 Severity:  normal       |   Resolution:            
 Keywords:  has-patch    |  
-------------------------+--------------------------------------------------
Changes (by koopersmith):

  * status:  closed => reopened
 * cc: koopersmith (added)
  * resolution:  wontfix =>
  * keywords:  => has-patch
  * type:  defect (bug) => enhancement


Comment:

 Actually, I've been playing around with the code and wrote a patch that
 keeps performance about the same, but improves accuracy.

 1. When the wordcount function is blocked, it will estimate the wordcount
 by adding one to the current wordcount when the spacebar is pressed.

 2. It updates on paste in tinymce and html mode, and a user selection in
 html mode (tinymce doesn't have an onSelect event for some reason).

 3. It centralizes the functionality between tinymce and html mode by
 passing the functions into the wcWordCount object.

 4. It times the wc function, and if the execution time is high enough it
 will increase the timeout threshold accordingly. Currently it's 100ms *
 execution time, with the default timeout set to 2000ms. This might require
 some tweaking.

 I thought about adding a few more features (like detecting when the user
 inserts a tag in html mode, and not incrementing), but that requires
 adding a keypress event. I think this is the best balance of performance
 and functionality.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/12921#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list