Help with chat code
Help with chat code
Hello
I am writing a chat application using XMPP...
http://www.arialboundaries.com/chatting
signin:
mary@blah.im
mary
You add a user to chat with (alotofmath@gmail.com, which is me), and then chat.
I hit a snag; the Javascript I am writing is not registering the enter key; it should work that, if you enter text, and press enter, the message should be recorded in the chat window.
$('.chat-input').on('keypress', function (ev) {
window.alert("I'm here");
var jid = $(this).parent().data('jid');
if (ev.which === 13) {
//ev.preventDefault();
window.alert("I'm here");
var body = $(this).val();
var message = $msg({to: jid,
"type": "chat"})
.c('body').t(body).up()
.c('active', {xmlns: "http://jabber.org/protocol/chatstates"});
Gab.connection.send(message);
$(this).parent().find('.chat-messages').append(
"<div class='chat-message'><" +
"<span class='chat-name me'>" +
Strophe.getNodeFromJid(Gab.connection.jid) +
"</span>><span class='chat-text'>" +
body +
"</span></div>");
Gab.scroll_chat(Gab.jid_to_id(jid));
$(this).val('');
$(this).parent().data('composing', false);
} else {
var composing = $(this).parent().data('composing');
if (!composing) {
var notify = $msg({to: jid, "type": "chat"})
.c('composing', {xmlns: "http://jabber.org/protocol/chatstates"});
Gab.connection.send(notify);
$(this).parent().data('composing', true);
}
This whole section is not being seen, I think.
Anyone know why? I had "live" instead of "on", but the change did not seem to help.
Thanks so much,
Michael