X-Git-Url: http://git.babelmonkeys.de/?a=blobdiff_plain;f=scripts%2Fbasic.js;h=e4a63cf114cbf309b0d4cccee1ce78beef3481ad;hb=7303f83ac4937931e7e48f150ef78a9ee0229b50;hp=aecaa7eeed3e062a490b4d5d5f2be1ccee3c815a;hpb=b12b35d39a99293eadee739b291f64433f5da34e;p=socialXMPP.git diff --git a/scripts/basic.js b/scripts/basic.js index aecaa7e..e4a63cf 100644 --- a/scripts/basic.js +++ b/scripts/basic.js @@ -122,7 +122,7 @@ function _cbOwnVCard(e) { } function getVCard(jid) { - var id = 'getvCard'+jid2id(jid); + var id = connection.getUniqueId('vCardGet'); if (roster[jid2id(jid)].vCard == "") { var vCardiq = $iq({'to':jid, 'id':id, @@ -136,7 +136,7 @@ function getVCard(jid) { } function getOwnInfo() { - var id = 'getvCard'+jid2id(connection.jid); + var id = connection.getUniqueId('vCardGet'); var vCardiq = $iq({'to': Strophe.getBareJidFromJid(connection.jid), 'id': id, 'type': 'get'} @@ -144,7 +144,6 @@ function getOwnInfo() { connection.addHandler(_cbOwnVCard, null, 'iq', 'result', id); connection.send(vCardiq.tree()); } - function addFriend(jid, nick) { roster[jid2id(jid)] = new Buddy(nick, jid); $('#friends').append('

'+nick+'
'); @@ -175,11 +174,13 @@ function _cbRoster(e) { var initialPresence = $pres().c('show').t('online').up().c('status').t('Hy, I am an socialXMPP instance').up().c('priority').t('1').up().c('c', {xmlns: NS_CAPS, hash: 'sha-1', node: 'http://jabber.babelmonkeys.de', ver: genCaps()}).up(); connection.send(initialPresence.tree()); + $('#friends').show(); + return false; } function getRoster() { - var id = 'getRoster'; + var id = connection.getUniqueId('roster'); var rosteriq = $iq({'id':id, 'type':'get'} @@ -209,7 +210,9 @@ function sendMessage(form, to) { var id = jid2id(to) + 'Chat'; var message = $msg({'type': 'chat', 'to': to}).c('body').t(form.text.value); connection.send(message.tree()); - $('#' + id + ' p').append('
'); + if ($('#' + id + ' p *').length > 0) { + $('#' + id + ' p').append('
'); + } $('#' + id + ' p').append('' + localJID + ': '); $('#' + id + ' p').append(form.text.value); form.text.value = ''; @@ -220,7 +223,8 @@ function sendMessage(form, to) { function createBubble(jid) { var id = jid2id(jid) + 'Chat'; - $('body').append('
Close

'); + $('body').append('
Close' + + ' ' + jid + '

'); $('#' + id).append('
') $('#' + id).css( 'top', $('#' + jid2id(jid)).position().top + 40); $('#' + id).css( 'left', $('#' + jid2id(jid)).position().left + 40); @@ -242,7 +246,9 @@ function _cbMessage(msg) { if ($('#' + id).length <= 0) { createBubble(jid); } - $('#' + id + ' p').append('
'); + if ($('#' + id + ' p *').length > 0) { + $('#' + id + ' p').append('
'); + } $('#' + id + ' p').append('' + jid + ': '); $('#' + id + ' p').append(body); $('#' + id).show(); @@ -326,7 +332,7 @@ function showConnect() { $('#log').empty(); $('#ownInfo').hide(); $('#vCard_container').empty(); - $('#friends').empty(); + $('#friends').hide(); $('.chat').remove(); $('label').show(); jid.show(); @@ -369,7 +375,6 @@ $(document).ready(function () { onConnect); } else { connection.disconnect(); - showConnect(); } return false; });