X-Git-Url: http://cgit.babelmonkeys.de/?p=socialXMPP.git;a=blobdiff_plain;f=scripts%2Fbasic.js;h=4fb36fab946d6c3cbf94002baaa0601b88f267d1;hp=934308c22fc1fc413305f34911545322d563514f;hb=43e0a653ab9ef78eb9b4e5e76dc615d2f3b72596;hpb=304a32ff55fe711e84fd2ca5ad0860adcf5e4a1b 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();