X-Git-Url: http://cgit.babelmonkeys.de/?p=adhocweb.git;a=blobdiff_plain;f=js%2Fmain.js;h=188dfc762eda4af93e1ac45659c9671bf8046d5f;hp=6bd32412743739166210a6cc07f5d3c9e3df1a29;hb=e3f2eb03a5f4dc014e034cdfc65a572544421336;hpb=e5d4fe480e02907b80e91d9ed42854700c5866c1 diff --git a/js/main.js b/js/main.js index 6bd3241..188dfc7 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"); @@ -143,7 +143,7 @@ function addForm(elem, x) { } function serializeToDataform(form, st) { - st.c("x", {"xmlns":"jabber:x:data", "type": "submit"}); + st.c("x", {"xmlns": "jabber:x:data", "type": "submit"}); $(form).find(".df-item").each(function(){ st.c("field", {"var": $(this).attr("name")}); if (this.nodeName.toLowerCase() == "select" && this.multiple) { @@ -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() { @@ -334,9 +339,8 @@ $(document).ready(function () { }); }); -onunload = function() { +window.onunload = window.onbeforeunload = function() { if (connection) { connection.disconnect(); } } -