/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */
/* This file is part of version 0.96beta2 released Fri, 20 Mar 2009 11:01:14 +0100 */
function CharCounter(a){this.editor=a;this._Chars=0;this._Words=0;this._HTML=0;this.onKeyPress=this.__onKeyPress}Xinha.Config.prototype.CharCounter={showChar:true,showWord:true,showHtml:true,separator:" | ",maxHTML:-1};CharCounter._pluginInfo={name:"CharCounter",version:"1.31",developer:"Udo Schmal",developer_url:"http://www.schaffrath-neuemedien.de",sponsor:"L.N.Schaffrath NeueMedien",sponsor_url:"http://www.schaffrath-neuemedien.de",c_owner:"Udo Schmal & L.N.Schaffrath NeueMedien",license:"htmlArea"};CharCounter.prototype._lc=function(a){return Xinha._lc(a,"CharCounter")};CharCounter.prototype.onGenerateOnce=function(){var b=this;if(this.charCount==null){var a=b.editor.registerStatusWidget("CharCounter",["wysiwyg"]);this.charCount=a}};CharCounter.prototype.__onKeyPress=function(b){if((b.keyCode!=8)&&(b.keyCode!=46)){if(this.editor.config.CharCounter.maxHTML!=-1){var a=this.editor.getHTML();if(a.length>=this.editor.config.CharCounter.maxHTML){Xinha._stopEvent(b);return true}}}};CharCounter.prototype._updateCharCount=function(){var d=this.editor;var b=d.config;var e=d.getHTML();var c=new Array();if(b.CharCounter.showHtml){c[c.length]=this._lc("HTML")+": "+e.length}this._HTML=e.length;if(b.CharCounter.showWord||b.CharCounter.showChar){e=e.replace(/<\/?\s*!--[^-->]*-->/gi,"");e=e.replace(/<(.+?)>/g,"");e=e.replace(/&nbsp;/gi," ");e=e.replace(/([\n\r\t])/g," ");e=e.replace(/(  +)/g," ");e=e.replace(/&(.*);/g," ");e=e.replace(/^\s*|\s*$/g,"")}if(b.CharCounter.showWord){this._Words=0;for(var a=0;a<e.length;a++){if(e.charAt(a)==" "){this._Words++}}if(this._Words>=1){this._Words++}c[c.length]=this._lc("Words")+": "+this._Words}if(b.CharCounter.showChar){c[c.length]=this._lc("Chars")+": "+e.length;this._Chars=e.length}this.charCount.innerHTML=c.join(b.CharCounter.separator)};CharCounter.prototype.onUpdateToolbar=function(){this.charCount.innerHTML=this._lc("... in progress");if(this._timeoutID){window.clearTimeout(this._timeoutID)}var a=this;this._timeoutID=window.setTimeout(function(){a._updateCharCount()},1000)};