Ignore:
Timestamp:
08/31/05 07:10:24 (14 years ago)
Author:
gocher
Message:

Plugin CharCounter?
Call updateCharCount only once by onUpdateToolbar

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/CharCounter/char-counter.js

    r244 r303  
    7070} 
    7171 
    72 CharCounter.prototype.onKeyPress = function(ev) { 
    73     var cnt = this.updateCharCount(); 
    74  
    75     //return true makes xinha ignoring the keypress, although for EVERY 
    76     //keypress (incl. navigating, deleting etc...) 
    77     //if(cnt > 100) return(true); 
    78 } 
    79  
    8072CharCounter.prototype.updateCharCount = function(ev) { 
    8173    editor = this.editor; 
    8274    var contents = editor.getHTML(); 
    8375    contents = contents.replace(/<(.+?)>/g, '');//Don't count HTML tags 
    84     contents = contents.replace(/([\n\r\t])/g, ' ');//convert newlines and tabs into space     
     76    contents = contents.replace(/([\n\r\t])/g, ' ');//convert newlines and tabs into space 
    8577    contents = contents.replace(/(  +)/g, ' ');//count spaces only once 
    8678    contents = contents.replace(/&(.*);/g, ' ');//Count htmlentities as one keystroke 
    8779    contents = contents.replace(/^\s*|\s*$/g, '');//trim 
     80//    var words=0; 
     81//    for (var x=0;x<contents.length;x++) { 
     82//      if (contents.charAt(x) == " " )  {words++} 
     83//    } 
     84//    this.charCount.innerHTML = this._lc("Words") + ": " + words + " | " + this._lc("Chars") + ": " + contents.length; 
    8885    this.charCount.innerHTML = this._lc("Chars") + ": " + contents.length; 
    8986    return(contents.length); 
Note: See TracChangeset for help on using the changeset viewer.