Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2007-02-05 11:44:02

datmw
New member
Registered: 2007-02-05
Posts: 2

Typing problem

Hallo!

I'm using Xinha on my page in a password-protected area, so I can't give you the url. I'll give you the code instead.

My problem is, that I installed and integrated Xinha in my project, everything is running fine, excepted typing new characters in the form.
I can insert tables, images, specialchars (using the plugin) and whatever I want. But when I hit a key on my keyboard (except backspace and delete) nothing happens.

The code of page:

 <script type="text/javascript">
    _editor_url  = "http://v7.ehlenz.net/xinha/";
    _editor_lang = "de";     
</script>

<script type="text/javascript" src="http://v7.ehlenz.net/xinha/my_config.js"></script>
<script type="text/javascript" src="http://v7.ehlenz.net/xinha/XinhaCore.js"></script>

<form method=post><textarea id="text" name="text" rows="10" cols="50" style="width: 100%">
{some text}</textarea><input type=hidden name='pass' value='teile'><input type=submit value='Abschicken'></form>

the my_config.js-file looks like this:

    xinha_editors = null;
    xinha_init    = null;
    xinha_config  = null;
    xinha_plugins = null;

    // This contains the names of textareas we will make into Xinha editors
    xinha_init = xinha_init ? xinha_init : function()
    {
      /** STEP 1 ***************************************************************
       * First, what are the plugins you will be using in the editors on this
       * page.  List all the plugins you will need, even if not all the editors
       * will use all the plugins.
       *
       * The list of plugins below is a good starting point, but if you prefer
       * a must simpler editor to start with then you can use the following 
       * 
       * xinha_plugins = xinha_plugins ? xinha_plugins : [ ];
       *
       * which will load no extra plugins at all.
       ************************************************************************/

      xinha_plugins = xinha_plugins ? xinha_plugins :
      [
       'CharCounter',
       'CharacterMap',
       'ContextMenu',
       'ExtendedFileManager',
       'FindReplace',
       'SmartReplace',
       'SpellChecker',
       'TableOperations'
      ];
             // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING  :)
             if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return;

      /** STEP 2 ***************************************************************
       * Now, what are the names of the textareas you will be turning into
       * editors?
       ************************************************************************/

      xinha_editors = xinha_editors ? xinha_editors :
      [
    'text'
      ];

      /** STEP 3 ***************************************************************
       * We create a default configuration to be used by all the editors.
       * If you wish to configure some of the editors differently this will be
       * done in step 5.
       *
       * If you want to modify the default config you might do something like this.
       *
       *   xinha_config = new Xinha.Config();
       *   xinha_config.width  = '640px';
       *   xinha_config.height = '420px';
       *
       *************************************************************************/

       xinha_config = xinha_config ? xinha_config() : new Xinha.Config();

      /** STEP 4 ***************************************************************
       * We first create editors for the textareas.
       *
       * You can do this in two ways, either
       *
       *   xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
       *
       * if you want all the editor objects to use the same set of plugins, OR;
       *
       *   xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config);
       *   xinha_editors['myTextArea'].registerPlugins(['Stylist','FullScreen']);
       *   xinha_editors['anotherOne'].registerPlugins(['CSS','SuperClean']);
       *
       * if you want to use a different set of plugins for one or more of the
       * editors.
       ************************************************************************/

      xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);

      /** STEP 5 ***************************************************************
       * If you want to change the configuration variables of any of the
       * editors,  this is the place to do that, for example you might want to
       * change the width and height of one of the editors, like this...
       *
       *   xinha_editors.myTextArea.config.width  = '640px';
       *   xinha_editors.myTextArea.config.height = '480px';
       *
       ************************************************************************/


      /** STEP 6 ***************************************************************
       * Finally we "start" the editors, this turns the textareas into
       * Xinha editors.
       ************************************************************************/

      Xinha.startEditors(xinha_editors);
    }

    window.onload = xinha_init;

Can anyone help me? [tested on Opera, IE and FF, all in the latest release on a windows platform]

Offline

#2 2007-02-05 14:34:53

jedi58
Xinha Authority
From: Leicester, UK
Registered: 2007-01-14
Posts: 113
Website

Re: Typing problem

try removing the CharCounter plugin


I had the same problem with it on Firefox for the mac....though strangely enough couldn't replicate the problem on windows


David G. Paul
[url]http://www.newearthonline.co.uk[/url]

Offline

#3 2007-02-06 07:18:19

datmw
New member
Registered: 2007-02-05
Posts: 2

Re: Typing problem

thx, now everything is fine.

Offline

#4 2007-02-06 09:11:19

jedi58
Xinha Authority
From: Leicester, UK
Registered: 2007-01-14
Posts: 113
Website

Re: Typing problem

glad it's not just me having trouble with CharCounter then!


David G. Paul
[url]http://www.newearthonline.co.uk[/url]

Offline

#5 2007-02-06 11:53:56

mokhet
Xinha Authority
From: Paris, France
Registered: 2005-04-03
Posts: 105
Website

Re: Typing problem

The problem with the charcounter plugin is quite simple. Once there is too many characters to count, it's not usable anymore. The plugin as it is actually is good for low characters. To fix the issue, i have updated the plugin to make it calculate the number of chars/words/HTML when we click on a toolbar button and not in real time anymore.

There is now a config variable to let you choose between "standard", "notifier" and "button" mode

editor.config.CharCounter.mode = 'standard';

This config let you use the plugin as it is actually, which means real time and the more chars to count, the slower it is.

editor.config.CharCounter.mode = 'notifier';

This config is here to use notifiers ('keypress_event' and 'content_update') but you can't use it since thoses notifiers does not exists in the actual Xinha version (it is something I need to commit on my branch, but still no time to do it correctly). I should removed it, it is useless for you.

editor.config.CharCounter.mode = 'button';

With this config mode, it will add a button (ed_charcounter.png) in the toolbar near the "createLink" button. So the calculation is not real time anymore, you calculating only when you click on the button.

Here is the version (based on 1.2, revision 563) i am using :

// Charcounter for HTMLArea-3.0
// (c) Udo Schmal & L.N.Schaffrath NeueMedien
// Distributed under the same terms as HTMLArea itself.
// This notice MUST stay intact for use (see license.txt).

function CharCounter(editor) {
  this.editor = editor;
  var e = this;
  function updater(N, T)
  {
    e.charCount.innerHTML = e._lc("... in progress");
    if ( e._timeoutID )
    {
      window.clearTimeout(e._timeoutID);
    }
    e._timeoutID = window.setTimeout(function() {e._updateCharCount();}, 1000);
  }
  switch ( editor.config.CharCounter.mode )
  {
    case 'notifier':
      editor.notifyOn(['content_update', 'keypress_event'], updater);
    break;
    case 'button':
      editor.config.registerButton(
        {
          id       : 'countcharacter',
          tooltip  : HTMLArea._lc( 'Character counter', 'CharCounter' ),
          image    : editor.imgURL( 'ed_charcounter.png', 'CharCounter' ),
          textMode : false,
          action   : updater
        }
      );
      editor.config.addToolbarElement('countcharacter', 'createlink', -1);
    break;
    default:
      this.onUpdateToolbar = updater;
    break;
  }
}

HTMLArea.Config.prototype.CharCounter =
{
  'showChar': true, // show the characters count,
  'showWord': true, // show the words count,
  'showHtml': true, // show the exact html count
  'separator': ' | ', // separator used to join informations
  mode: 'button' // preferered method to update counters (standard, notifier, button)
};

CharCounter._pluginInfo = {
  name          : "CharCounter",
  version       : "1.2",
  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(string) {
    return HTMLArea._lc(string, "CharCounter");
};


CharCounter.prototype.onGenerate = function() {
  var self = this;
  if (this.charCount==null) {
    var charCount = document.createElement("span");
    charCount.style.padding = "2px 5px";
    charCount.style[HTMLArea.is_ie ? 'styleFloat' : 'cssFloat'] = "right";
    var brk = document.createElement('div');
    brk.style.height =
    brk.style.width =
    brk.style.lineHeight =
    brk.style.fontSize = '1px';
    brk.style.clear = 'both';
    this.editor._statusBarTree.style[HTMLArea.is_ie ? 'styleFloat' : 'cssFloat'] = "left";
    this.editor._statusBar.appendChild(charCount);
    this.editor._statusBar.appendChild(brk);
    this.charCount = charCount;
  }
};

CharCounter.prototype._updateCharCount = function() {
  var editor = this.editor;
  var cfg = editor.config;
  var contents = editor.getHTML();
  var string = [];
  if (cfg.CharCounter.showHtml) {
    string[string.length] = this._lc("HTML") + ": " + contents.length;
  }
  if (cfg.CharCounter.showWord || cfg.CharCounter.showChar) {
    contents = contents.replace(/<\/?\s*!--[^-->]*-->/gi, "" );
    contents = contents.replace(/<(.+?)>/g, '');//Don't count HTML tags
    contents = contents.replace(/ /gi, ' ');
    contents = contents.replace(/([\n\r\t])/g, ' ');//convert newlines and tabs into space
    contents = contents.replace(/(  +)/g, ' ');//count spaces only once
    contents = contents.replace(/&(.*);/g, ' ');//Count htmlentities as one keystroke
    contents = contents.replace(/^\s*|\s*$/g, '');//trim
  }
  if (cfg.CharCounter.showWord) {
    var words=0;
    for (var x=0;x<contents.length;x++)
    {
      if (contents.charAt(x) == " " ) {words++;}
    }
    if (words>=1) { words++; }
    string[string.length] = this._lc("Words") + ": " + words;
  }

  if (cfg.CharCounter.showChar) {
    string[string.length] = this._lc("Chars") + ": " + contents.length;
  }

  this.charCount.innerHTML = string.join(cfg.CharCounter.separator);
};

CharCounter.prototype.onMode = function (mode)
{
  //Hide Chars in statusbar when switching into textmode
  switch (mode)
  {
    case "textmode":
      this.charCount.style.display = "none";
      break;
    case "wysiwyg":
      this.charCount.style.display = "";
      break;
    default:
      alert("Mode <" + mode + "> not defined!");
      return false;
  }
  return true;
};

Hope it helps.

Offline

#6 2007-02-07 05:45:15

jedi58
Xinha Authority
From: Leicester, UK
Registered: 2007-01-14
Posts: 113
Website

Re: Typing problem

yay, thats an excellent update smile can use it on the mac now too (maybe the mac has a lower limit on the number of characters before it goes crazy)


David G. Paul
[url]http://www.newearthonline.co.uk[/url]

Offline

Board footer

Powered by FluxBB