From: Florian Zeitz Date: Wed, 6 Oct 2010 21:49:29 +0000 (+0200) Subject: More robust fetching of features X-Git-Url: https://git.babelmonkeys.de/?a=commitdiff_plain;h=9ba3402321b224b65cc3eed994b6cb016cfeabda;p=adhocweb.git More robust fetching of features * Only request items if adhoc feature is present * Implement errback --- diff --git a/js/main.js b/js/main.js index 6bd3241..c03a8cf 100644 --- a/js/main.js +++ b/js/main.js @@ -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"); @@ -260,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("

This entitiy does support AdHoc commands

"); - } else { - $('#output').append("

This entitiy does NOT support AdHoc commands

"); - } - }); $('#output').empty(); - getCommandNodes(); + connection.sendIQ(featureIQ, + function(result) { /* Callback */ + if ($(result).find("feature[var='" + Strophe.NS.ADHOC + "']").length > 0) { + $('#output').append("

This entitiy does support AdHoc commands

"); + getCommandNodes(); + } else { + $('#output').append("

This entitiy does NOT support AdHoc commands

"); + } + }, + function(result) { /* Errback */ + $('#output').append("

Couldn't get list of supported features

"); + } + ); } function showConnect() {