From: Florian Zeitz Date: Thu, 9 Apr 2009 19:17:24 +0000 (+0200) Subject: Basic message receiving support X-Git-Url: https://git.babelmonkeys.de/?a=commitdiff_plain;h=43e0a653ab9ef78eb9b4e5e76dc615d2f3b72596;p=socialXMPP.git Basic message receiving support --- diff --git a/css/standard.css b/css/standard.css index 31a1782..1792f53 100644 --- a/css/standard.css +++ b/css/standard.css @@ -39,3 +39,7 @@ max-width: 70px; max-height: 70px; } + +.sender { + color: blue; +} diff --git a/scripts/basic.js b/scripts/basic.js index 934308c..4fb36fa 100644 --- a/scripts/basic.js +++ b/scripts/basic.js @@ -127,7 +127,6 @@ function getVCard(jid) { } else { _cbVCard(roster[jid2id(jid)].vCard); } - } function getOwnInfo() { @@ -191,6 +190,27 @@ function _cbDisco(e) { return true; } +function _cbMessage(msg) { + var jid = $(msg).attr('from'); + var id = jid2id($(msg).attr('from')) + 'Chat'; + var body = $(msg).find('body:first').text(); + body = escape(body); + body = body.replace(/%0A/g, '
'); + body = body.replace(/%3C/g, '<'); + body = body.replace(/%3E/g, '>'); + body = body.replace(/%26/g, '&'); + body = unescape(body); + if ($('#' + id).length > 0) { + $('#' + id + ' p').append('
'); + $('#' + id + ' p').append('' + jid + ': '); + $('#' + id + ' p').append(body); + } else { + $('body').append('

' + jid + ': ' + body + '

'); + } + + return true; +} + function genCaps() { var S = ''; S += 'client/web//' + appName + '<' @@ -252,6 +272,7 @@ function onConnect(status) { getOwnInfo(); getRoster(); connection.addHandler(_cbDisco, Strophe.NS.DISCO_INFO, 'iq', 'get'); + connection.addHandler(_cbMessage, Strophe.NS.CLIENT, 'message'); } } @@ -264,6 +285,7 @@ function showConnect() { $('#ownInfo').hide(); $('#vCard_container').empty(); $('#friends').empty(); + $('.chat').remove(); $('label').show(); jid.show(); pass.show();