General > General Discussion

how can i send message by pressing enter key

<< < (2/2)

Caba:
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... ;)

squirrelist:
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.

Inspirer:
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

mihainord:
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.

Navigation

[0] Message Index

[*] Previous page

Go to full version