Changeset 619
- Timestamp:
- 12/14/06 14:50:24 (6 years ago)
- Files:
-
- 1 modified
-
trunk/plugins/CharCounter/char-counter.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/CharCounter/char-counter.js
r512 r619 6 6 function CharCounter(editor) { 7 7 this.editor = editor; 8 this._Chars = 0; 9 this._Words = 0; 10 this._HTML = 0; 11 this.maxHTML = 1024; 12 this.onKeyPress = this.__onKeyPress; 8 13 } 9 14 … … 18 23 CharCounter._pluginInfo = { 19 24 name : "CharCounter", 20 version : "1. 2",25 version : "1.3", 21 26 developer : "Udo Schmal", 22 27 developer_url : "http://www.schaffrath-neuemedien.de", … … 59 64 }; 60 65 61 CharCounter.prototype._updateCharCount = function() { 66 CharCounter.prototype.__onKeyPress= function(ev) { 67 if ((ev.keyCode != 8) && (ev.keyCode !=46)) { // not backspace & delete 68 if (this.maxHTML!=-1) { 69 var contents = this.editor.getHTML(); 70 if (contents.length>=this.maxHTML) { 71 HTMLArea._stopEvent(ev); 72 return true; 73 } 74 } 75 } 76 } 77 78 CharCounter.prototype._updateCharCount= function() { 62 79 var editor = this.editor; 63 80 var cfg = editor.config; … … 67 84 string[string.length] = this._lc("HTML") + ": " + contents.length; 68 85 } 86 this._HTML = contents.length; 69 87 if (cfg.CharCounter.showWord || cfg.CharCounter.showChar) { 70 88 contents = contents.replace(/<\/?\s*!--[^-->]*-->/gi, "" ); … … 77 95 } 78 96 if (cfg.CharCounter.showWord) { 79 var words=0;97 this._Words = 0; 80 98 for (var x=0;x<contents.length;x++) 81 99 { 82 if (contents.charAt(x) == " " ) { words++;}100 if (contents.charAt(x) == " " ) {this._Words++;} 83 101 } 84 if ( words>=1) { words++; }85 string[string.length] = this._lc("Words") + ": " + words;102 if (this._Words >=1) { this._Words++; } 103 string[string.length] = this._lc("Words") + ": " + this._Words ; 86 104 } 87 88 105 if (cfg.CharCounter.showChar) { 89 106 string[string.length] = this._lc("Chars") + ": " + contents.length; 107 this._Chars = contents.length; 90 108 } 91 92 109 this.charCount.innerHTML = string.join(cfg.CharCounter.separator); 93 110 };
