Changeset 432
- Timestamp:
- 12/09/05 12:11:52 (7 years ago)
- Files:
-
- 1 modified
-
trunk/plugins/CharCounter/char-counter.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/CharCounter/char-counter.js
r419 r432 8 8 } 9 9 10 HTMLArea.Config.prototype.CharCounter = 11 { 12 'showChar': true, // show the characters count, 13 'showWord': true, // show the words count, 14 'showHtml': true, // show the exact html count 15 'separator': ' | ' // separator used to join informations 16 }; 17 10 18 CharCounter._pluginInfo = { 11 19 name : "CharCounter", 12 version : "1. 0",20 version : "1.1", 13 21 developer : "Udo Schmal", 14 22 developer_url : "http://www.schaffrath-neuemedien.de", … … 73 81 74 82 CharCounter.prototype.updateCharCount = function(ev) { 75 editor = this.editor; 83 var editor = this.editor; 84 var cfg = editor.config; 76 85 var contents = editor.getHTML(); 86 var string = new Array(); 87 if (cfg.CharCounter.showHtml) { 88 string[string.length] = this._lc("HTML") + ": " + contents.length; 89 } 90 if (cfg.CharCounter.showWord) { 91 contents = contents.replace(/<\/?\s*!--[^-->]*-->/gi, "" ); 77 92 contents = contents.replace(/<(.+?)>/g, '');//Don't count HTML tags 93 contents = contents.replace(/ /gi, ' '); 78 94 contents = contents.replace(/([\n\r\t])/g, ' ');//convert newlines and tabs into space 79 95 contents = contents.replace(/( +)/g, ' ');//count spaces only once 80 96 contents = contents.replace(/&(.*);/g, ' ');//Count htmlentities as one keystroke 81 97 contents = contents.replace(/^\s*|\s*$/g, '');//trim 82 // var words=0; 83 // for (var x=0;x<contents.length;x++) { 84 // if (contents.charAt(x) == " " ) {words++} 85 // } 86 // this.charCount.innerHTML = this._lc("Words") + ": " + words + " | " + this._lc("Chars") + ": " + contents.length; 87 this.charCount.innerHTML = this._lc("Chars") + ": " + contents.length; 88 return(contents.length); 98 var words=0; 99 for (var x=0;x<contents.length;x++) 100 { 101 if (contents.charAt(x) == " " ) {words++;} 102 } 103 if (words>=1) { words = words+1; } 104 string[string.length] = this._lc("Words") + ": " + words; 105 } 106 107 if (cfg.CharCounter.showChar) { 108 string[string.length] = this._lc("Chars") + ": " + contents.length; 109 } 110 111 this.charCount.innerHTML = string.join(cfg.CharCounter.separator); 89 112 };
