]> cgit.babelmonkeys.de Git - socialXMPP.git/blobdiff - scripts/basic.js
Small message changes/fixes and consistency change
[socialXMPP.git] / scripts / basic.js
index 4fb36fab946d6c3cbf94002baaa0601b88f267d1..1ef91154cde0c8947ce8b8640079757c41b66870 100644 (file)
@@ -13,7 +13,7 @@ var appName = 'socialXMPP';
 var roster = new Array();
 
 function log(msg) {
-    var entry = $('<div></div>').append(Strophe.xmlTextNode(msg));
+    var entry = $('<div></div>').append(document.createTextNode(msg));
     $('#log').append(entry);
 }
 
@@ -158,7 +158,7 @@ function _cbRoster(e) {
        addFriend(entries[item].getAttribute('jid'), nick);
     }
     connection.addHandler(_cbPEP, NS_PEP, 'message');
-    var initialPresence = $pres().c('c', {xmlns: NS_CAPS, hash: 'sha-1', node: 'http://jabber.babelmonkeys.de', ver: genCaps()}).up();
+    var initialPresence = $pres().c('show').t('online').up().c('status').t('Hy, I am an socialXMPP instance').up().c('priority').t('0').up().c('c', {xmlns: NS_CAPS, hash: 'sha-1', node: 'http://jabber.babelmonkeys.de', ver: genCaps()}).up();
     connection.send(initialPresence.tree());
 
     return false;
@@ -191,6 +191,8 @@ function _cbDisco(e) {
 }
 
 function _cbMessage(msg) {
+    if ($(msg).attr('type') != 'chat')
+       return;
     var jid = $(msg).attr('from');
     var id = jid2id($(msg).attr('from')) + 'Chat';
     var body = $(msg).find('body:first').text();
@@ -257,7 +259,6 @@ function _cbPEP(e) {
 function onConnect(status) {
     if (status == Strophe.Status.CONNECTING) {
        log('Strophe is connecting.');
-
     } else if (status == Strophe.Status.CONNFAIL) {
        log('Strophe failed to connect.');
        showConnect();
@@ -266,7 +267,10 @@ function onConnect(status) {
     } else if (status == Strophe.Status.DISCONNECTED) {
        log('Strophe is disconnected.');
        showConnect();
-
+    } else if (status == Strophe.Status.AUTHFAIL) {
+       log('Authentication failed.');
+       connection.disconnect();
+       showConnect();
     } else if (status == Strophe.Status.CONNECTED) {
        log('Strophe is connected.');
        getOwnInfo();