Changeset 303 for trunk/plugins/CharCounter
- Timestamp:
- 08/31/05 07:10:24 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/CharCounter/char-counter.js
r244 r303 70 70 } 71 71 72 CharCounter.prototype.onKeyPress = function(ev) {73 var cnt = this.updateCharCount();74 75 //return true makes xinha ignoring the keypress, although for EVERY76 //keypress (incl. navigating, deleting etc...)77 //if(cnt > 100) return(true);78 }79 80 72 CharCounter.prototype.updateCharCount = function(ev) { 81 73 editor = this.editor; 82 74 var contents = editor.getHTML(); 83 75 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 85 77 contents = contents.replace(/( +)/g, ' ');//count spaces only once 86 78 contents = contents.replace(/&(.*);/g, ' ');//Count htmlentities as one keystroke 87 79 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; 88 85 this.charCount.innerHTML = this._lc("Chars") + ": " + contents.length; 89 86 return(contents.length);
Note: See TracChangeset
for help on using the changeset viewer.