]> cgit.babelmonkeys.de Git - adhocweb.git/blobdiff - js/main.js
More robust fetching of features
[adhocweb.git] / js / main.js
index 1011dc87e58a9f4361130410e82282db34bb12c2..c03a8cf74c391428363da43a2f1269f1fb40d9c3 100644 (file)
@@ -1,5 +1,5 @@
 var BOSH_SERVICE = 'http://localhost:5280/http-bind/';
-var show_log = false;
+var show_log = true;
 
 Strophe.addNamespace("ADHOC", "http://jabber.org/protocol/commands");
 
@@ -51,6 +51,7 @@ function addNote(elem, text, type) {
     if (!type) {
        type = "info";
     }
+    text = text.replace(/\n/g, "<br/>");
     $(elem).append("<p class='" + type + "Note'>" + text + "</p>");
 }
 
@@ -87,7 +88,7 @@ function addForm(elem, x) {
             item = $("<input type='text'/>").attr("readonly",true);
             break;
         case "jid-multi":
-            item = $("<textarea rows='10' cols'70'/>");
+            item = $("<textarea rows='10' cols='70'/>");
             break;
         case "jid-single":
             item = $("<input type='text'/>");
@@ -259,15 +260,20 @@ function getCommandNodes() {
 
 function checkFeatures() {
     featureIQ = $iq({ type: "get", to: queryJID, id: "features1" }).c("query", {xmlns: Strophe.NS.DISCO_INFO});
-    connection.sendIQ(featureIQ, function(result) {
-        if ($(result).find("feature[var='" + Strophe.NS.ADHOC + "']").length > 0) {
-            $('#output').append("<p>This entitiy does support AdHoc commands</p>");
-        } else {
-            $('#output').append("<p>This entitiy does NOT support AdHoc commands</p>");
-        }
-    });
     $('#output').empty();
-    getCommandNodes();
+    connection.sendIQ(featureIQ,
+        function(result) { /* Callback */
+                if ($(result).find("feature[var='" + Strophe.NS.ADHOC + "']").length > 0) {
+                    $('#output').append("<p>This entitiy does support AdHoc commands</p>");
+                    getCommandNodes();
+                } else {
+                    $('#output').append("<p>This entitiy does NOT support AdHoc commands</p>");
+                }
+        },
+        function(result) { /* Errback */
+            $('#output').append("<p>Couldn't get list of supported features</p>");
+        }
+    );
 }
 
 function showConnect() {