Mibew Messenger Community

General => General Discussion => Topic started by: raj123 on February 04, 2009, 11:22:27 AM

Title: how can i send message by pressing enter key
Post by: raj123 on February 04, 2009, 11:22:27 AM
Hello,

webim working fine.

our clients wants by pessing enter key message has to send.

how can i send message by pressing enter key.

so Let me know where i have to make changes(i.e.  file name)


Arockia Raj
Title: Re: how can i send message by pressing enter key
Post by: thisgarryhas2rs on March 02, 2009, 09:49:00 PM
I'd like to know this to. This would be useful since people are used to just hitting Enter.
Title: Re: how can i send message by pressing enter key
Post by: squirrelist on March 06, 2009, 02:14:46 PM
Agreed!
Title: Re: how can i send message by pressing enter key
Post by: Caba on March 06, 2009, 04:47:17 PM
Hello everyone!
I´d like too knowing how to do this!
Thanks!
Title: Re: how can i send message by pressing enter key
Post by: squirrelist on March 06, 2009, 07:31:35 PM
I discovered that on Opera it's simply "Enter". Don't know if that helps anyone find the code that needs to be modified.
Title: Re: how can i send message by pressing enter key
Post by: Caba on March 10, 2009, 11:22:59 PM
Hi everyone!
Finally! After two long nights studying the code I found a way to send messages by pressing Enter key!
The key is in /js/chat.js in a function called function(k) (better look for it using a editor). This function uses two variables: k and kh to store the ASCII code of each one of the characters we enter in the textarea and the ASCII code for the CTRL key; so, the first step is to remove this kh variable (inside the if-else structure near to the declaration of the function).
The second step is to remove the myRealAgent variable from the condition clausule:if(this.pq.xt&&((k==015&&(kh||myRealAgent=='o\160er\141'))||(k==012))) (also remove kh)
After this two steps we should get a function like this:
function(k){if(k){k=k.which;} else{k=event.keyCode;} if(this.pq.xt&&((k==015)||(k==012))){...}.
Finally, we should change the message that appears in the bottom-right corner of the chat window (CTRL-Enter) by editing the file /libs/chat.php. Search for $page['send_shortcut'] PHP variable and change its value for "Enter" (for example).
Restart the chat! Et voilá! (unless it worked perfectly in IE and Firefox, don´t know Opera nor Safari, sorry ;D).
Hope this may be useful!
Bye!
PD: Sorry for my English... ;)
Title: Re: how can i send message by pressing enter key
Post by: squirrelist on March 11, 2009, 12:09:06 AM
Thank you Caba!

Attached are the two files which I have edited with your instructions. Confirmed working on Safari 4 for Mac. I'll check it with Safari 3 and Opera tomorrow.

Please consider using this code in the next release or at least providing an option in the interface to switch.
Title: Re: how can i send message by pressing enter key
Post by: Inspirer on March 12, 2009, 01:31:12 AM
Hi everyone!

Of course, I'll add this option in 1.6.

You can download the original (not minimized/obfuscated javascript here):
http://mibew.org/forums/index.php?topic=86.msg238#msg238

Have to remove some code in chat.js:
  handleKeyDown: function(k) {
   if( k ){ ctrl=k.ctrlKey;k=k.which; } else { k=event.keyCode;ctrl=event.ctrlKey;   }
   if( this._options.message && ((k==13 && (ctrl || myRealAgent == 'opera')) || (k==10)) ) {
      var mmsg = this._options.message.value;


AND

   'a#sndmessagelnk' : function(el) {
      if( myRealAgent == 'opera' ) {
         el.innerHTML = el.innerHTML.replace('Ctrl-','');
      }
   },

PS: it is exactly the same as Caba done
Title: Re: how can i send message by pressing enter key
Post by: mihainord on April 02, 2009, 06:27:15 AM
Great. I've also made the modification.

As a footnote I'd like to add that this script beats a lot of very expensive other same-purpose scripts. I hope it'll evolve faster and faster and people start donating because it would be great to see this script recongnized by many others as one of the best out there.