+var DEBUG = false;
+var BOSH_SERVICE = '/http-bind/';
+
var NS_VCARD = 'vcard-temp';
var NS_CAPS= 'http://jabber.org/protocol/caps';
var NS_PEP = 'http://jabber.org/protocol/pubsub#event';
var NS_TUNE = 'http://jabber.org/protocol/tune';
-var BOSH_SERVICE = 'http://localhost:5280/http-bind/';
var localJID = null;
var connection = null;
$("#PHOTO img").attr('src', 'data:'+mime+';base64,'+binval);
}
$(e).find('TEL:has(HOME)').each(function() {
+ $('#TELHOME').append(' ');
$('#TELHOME').append(Strophe.xmlTextNode($(this).find('NUMBER').text()));
});
$(e).find('TEL:has(WORK)').each(function() {
+ $('#TELWORK').append(' ');
$('#TELWORK').append(Strophe.xmlTextNode($(this).find('NUMBER').text()));
});
$(e).find('EMAIL:has(HOME)').each(function() {
+ $('#EMAILHOME').append(' ');
$('#EMAILHOME').append(Strophe.xmlTextNode($(this).find('USERID').text()));
});
$(e).find('EMAIL:has(WORK)').each(function() {
+ $('#EMAILWORK').append(' ');
$('#EMAILWORK').append(Strophe.xmlTextNode($(this).find('USERID').text()));
});
+ if (!roster[jid2id(jid)].tune.isEmpty()) {
+ $('#vCard ul').append('<li id="tune"><span class="vCardName">Tune: </span>Listening to '+
+ roster[jid2id(jid)].tune.title + ' by ' + roster[jid2id(jid)].tune.artist +
+ ' from ' + roster[jid2id(jid)].tune.source + '</li>')
+ }
+
$('#vCard').click(function () {
- $('#box-overlay').hide();
- $('#vCard_container').slideUp("normal");
+ $('#vCard_container').slideUp("normal", function() {
+ $('#box-overlay').hide();
+ });
+ roster[jid2id(jid)].visible = false;
});
$('#box-overlay').show();
$('#vCard_container').slideDown("normal");
+ roster[jid2id(jid)].visible = true;
}
function _cbVCard(e) {
function getOwnInfo() {
var id = connection.getUniqueId('vCardGet');
- var vCardiq = $iq({'to': Strophe.getBareJidFromJid(connection.jid),
- 'id': id,
- 'type': 'get'}
+ var vCardiq = $iq({'id': id, 'type': 'get'}
).c('vCard', {'xmlns':NS_VCARD});
connection.addHandler(_cbOwnVCard, null, 'iq', 'result', id);
connection.send(vCardiq.tree());
}
+
function addFriend(jid, nick) {
roster[jid2id(jid)] = new Buddy(nick, jid);
$('#friends').append('<div class="friend" id="'+jid2id(jid)+'"><img src="imgs/none.png" /><br /><a class="nick">'+nick+'</a></div>');
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();
+ $('#friends').css('display', 'table');
return false;
}
var id = e.getAttribute('id');
var jid = e.getAttribute('from');
- var response = $iq({id: id, type: 'result', to: jid});
+ if (jid) {
+ var response = $iq({id: id, type: 'result', to: jid});
+ } else {
+ var response = $iq({id: id, type: 'result'});
+ }
var query = response.c('query', {xmlns: Strophe.NS.DISCO_INFO})
query.c('identity', {category: 'client', type: 'web', name: appName}).up();
for (var i = 0; i < features.length; i++) {
return b64_sha1(S);
}
+function handleTune(jid, tuneXML) {
+ var tune = new Tune();
+ if (tuneXML.childNodes.length > 0) {
+ tune.artist = Strophe.getText(tuneXML.getElementsByTagName('artist')[0]);
+ tune.length= Strophe.getText(tuneXML.getElementsByTagName('length')[0]);
+ tune.rating= Strophe.getText(tuneXML.getElementsByTagName('rating')[0]);
+ tune.source= Strophe.getText(tuneXML.getElementsByTagName('source')[0]);
+ tune.title= Strophe.getText(tuneXML.getElementsByTagName('title')[0]);
+ tune.track= Strophe.getText(tuneXML.getElementsByTagName('track')[0]);
+ tune.uri= Strophe.getText(tuneXML.getElementsByTagName('uri')[0]);
+ if (roster[jid2id(jid)].visible == true) {
+ if ( $('#tune').length > 0) {
+ $('#tune').empty();
+ $('#tune').append('<span class="vCardName">Tune: </span>');
+ $('#tune').append(Strophe.xmlTextNode('Listening to '+ tune.title +
+ ' by ' + tune.artist + ' from ' + tune.source));
+ } else {
+ $('#vCard ul').append('<li id="tune"><span class="vCardName">Tune: </span>Listening to '+ tune.title +
+ ' by ' + tune.artist + ' from ' + tune.source + '</li>')
+ }
+ }
+ } else {
+ $('#tune').remove();
+ }
+ roster[jid2id(jid)].tune = tune;
+}
+
function _cbPEP(e) {
var from = e.getAttribute('from');
if (Strophe.getBareJidFromJid(from) == Strophe.getBareJidFromJid(connection.jid)) {
var items = e.getElementsByTagName('items')[0];
// Handle Tune
if (items.getAttribute('node') == NS_TUNE) {
- var tune = new Tune();
- if (items.getElementsByTagName('tune')[0].childNodes.length > 0) {
- tune.artist = Strophe.getText(items.getElementsByTagName('artist')[0]);
- tune.length= Strophe.getText(items.getElementsByTagName('length')[0]);
- tune.rating= Strophe.getText(items.getElementsByTagName('rating')[0]);
- tune.source= Strophe.getText(items.getElementsByTagName('source')[0]);
- tune.title= Strophe.getText(items.getElementsByTagName('title')[0]);
- tune.track= Strophe.getText(items.getElementsByTagName('track')[0]);
- tune.uri= Strophe.getText(items.getElementsByTagName('uri')[0]);
- if ( $('#'+jid2id(from)+' .tune').length > 0 ) {
- $('#'+jid2id(from)+' .tune').empty();
- $('#'+jid2id(from)+' .tune').append(Strophe.xmlTextNode('Listening to '+ tune.title + ' by ' + tune.artist + ' from ' + tune.source));
- } else {
- $('#'+jid2id(from)).append('<br /><span class="tune">Listening to '+ tune.title + ' by ' + tune.artist + ' from ' + tune.source + '</span>');
- }
- } else {
- if ( $('#'+jid2id(from)+' .tune').length > 0 ) {
- $('#'+jid2id(from)+' .tune').empty();
- }
- }
- roster[jid2id(from)].tune = tune;
+ handleTune(from, items.getElementsByTagName('tune')[0]);
}
return true;
}
}
$(document).ready(function () {
+ if (DEBUG) {
+ $('#log_container').show();
+ }
connection = new Strophe.Connection(BOSH_SERVICE);
connection.rawInput = rawInput;
connection.rawOutput = rawOutput;