| 19 | | name : "CharCounter", |
| 20 | | version : "1.1", |
| 21 | | developer : "Udo Schmal", |
| 22 | | developer_url : "http://www.schaffrath-neuemedien.de", |
| 23 | | sponsor : "L.N.Schaffrath NeueMedien", |
| 24 | | sponsor_url : "http://www.schaffrath-neuemedien.de", |
| 25 | | c_owner : "Udo Schmal & L.N.Schaffrath NeueMedien", |
| 26 | | license : "htmlArea" |
| | 19 | name : "CharCounter", |
| | 20 | version : "1.2", |
| | 21 | developer : "Udo Schmal", |
| | 22 | developer_url : "http://www.schaffrath-neuemedien.de", |
| | 23 | sponsor : "L.N.Schaffrath NeueMedien", |
| | 24 | sponsor_url : "http://www.schaffrath-neuemedien.de", |
| | 25 | c_owner : "Udo Schmal & L.N.Schaffrath NeueMedien", |
| | 26 | license : "htmlArea" |
| | 61 | CharCounter.prototype._updateCharCount = function() { |
| | 62 | var editor = this.editor; |
| | 63 | var cfg = editor.config; |
| | 64 | var contents = editor.getHTML(); |
| | 65 | var string = new Array(); |
| | 66 | if (cfg.CharCounter.showHtml) { |
| | 67 | string[string.length] = this._lc("HTML") + ": " + contents.length; |
| | 68 | } |
| | 69 | if (cfg.CharCounter.showWord || cfg.CharCounter.showChar) { |
| | 70 | contents = contents.replace(/<\/?\s*!--[^-->]*-->/gi, "" ); |
| | 71 | contents = contents.replace(/<(.+?)>/g, '');//Don't count HTML tags |
| | 72 | contents = contents.replace(/ /gi, ' '); |
| | 73 | contents = contents.replace(/([\n\r\t])/g, ' ');//convert newlines and tabs into space |
| | 74 | contents = contents.replace(/( +)/g, ' ');//count spaces only once |
| | 75 | contents = contents.replace(/&(.*);/g, ' ');//Count htmlentities as one keystroke |
| | 76 | contents = contents.replace(/^\s*|\s*$/g, '');//trim |
| | 77 | } |
| | 78 | if (cfg.CharCounter.showWord) { |
| | 79 | var words=0; |
| | 80 | for (var x=0;x<contents.length;x++) |
| | 81 | { |
| | 82 | if (contents.charAt(x) == " " ) {words++;} |
| | 83 | } |
| | 84 | if (words>=1) { words++; } |
| | 85 | string[string.length] = this._lc("Words") + ": " + words; |
| | 86 | } |
| | 87 | |
| | 88 | if (cfg.CharCounter.showChar) { |
| | 89 | string[string.length] = this._lc("Chars") + ": " + contents.length; |
| | 90 | } |
| | 91 | |
| | 92 | this.charCount.innerHTML = string.join(cfg.CharCounter.separator); |
| | 93 | }; |
| | 94 | |
| 81 | | |
| 82 | | CharCounter.prototype.updateCharCount = function(ev) { |
| 83 | | var editor = this.editor; |
| 84 | | var cfg = editor.config; |
| 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 || cfg.CharCounter.showChar) { |
| 91 | | contents = contents.replace(/<\/?\s*!--[^-->]*-->/gi, "" ); |
| 92 | | contents = contents.replace(/<(.+?)>/g, '');//Don't count HTML tags |
| 93 | | contents = contents.replace(/ /gi, ' '); |
| 94 | | contents = contents.replace(/([\n\r\t])/g, ' ');//convert newlines and tabs into space |
| 95 | | contents = contents.replace(/( +)/g, ' ');//count spaces only once |
| 96 | | contents = contents.replace(/&(.*);/g, ' ');//Count htmlentities as one keystroke |
| 97 | | contents = contents.replace(/^\s*|\s*$/g, '');//trim |
| 98 | | } |
| 99 | | if (cfg.CharCounter.showWord) { |
| 100 | | var words=0; |
| 101 | | for (var x=0;x<contents.length;x++) |
| 102 | | { |
| 103 | | if (contents.charAt(x) == " " ) {words++;} |
| 104 | | } |
| 105 | | if (words>=1) { words++; } |
| 106 | | string[string.length] = this._lc("Words") + ": " + words; |
| 107 | | } |
| 108 | | |
| 109 | | if (cfg.CharCounter.showChar) { |
| 110 | | string[string.length] = this._lc("Chars") + ": " + contents.length; |
| 111 | | } |
| 112 | | |
| 113 | | this.charCount.innerHTML = string.join(cfg.CharCounter.separator); |
| 114 | | }; |