X-Git-Url: http://cgit.babelmonkeys.de/?p=adhocweb.git;a=blobdiff_plain;f=js%2Fmain.js;h=621596162d3ce61b9068efa0eed6c07c7fd9605e;hp=15a0fd079a41a87b3d9f4a807495856c41e42486;hb=5a45869a032410c17d02374b8de20e496c114de3;hpb=b2d5c1947805fa3282ffc4762fe08620fba46c44 diff --git a/js/main.js b/js/main.js index 15a0fd0..6215961 100644 --- a/js/main.js +++ b/js/main.js @@ -1,11 +1,11 @@ var BOSH_SERVICE = 'http://localhost:5280/http-bind/'; var show_log = true; -Strophe.addNamespace("ADHOC", "http://jabber.org/protocol/commands"); - var localJID = null; var connection = null; +var commandCenter = null; + function log(msg) { var entry = $('
').append(document.createTextNode(msg)); $('#log').append(entry); @@ -19,6 +19,17 @@ function rawOutput(data) { log('SENT: ' + data); } +function getFeatures(jid) { + var cb, ecb; + cb = function(result) { /* Callback */ + commandCenter.getCommandNodes(function(items) { $('#output').empty(); $('#output').append(items) }); + } + ecb = function(result) { /* Errback */ + $('#output').append("

" + jid + " does NOT support AdHoc commands

"); + } + commandCenter.checkFeatures(jid, cb, ecb); +} + function onConnect(status) { if (status == Strophe.Status.CONNECTING) { log('Strophe is connecting.'); @@ -39,7 +50,13 @@ function onConnect(status) { log('Strophe is connected.'); $('#queryJID').val(connection.domain); $('#query').show(); - Adhoc.checkFeatures("#output", connection.domain); + commandCenter = new Adhoc("#output", function() { + $("").bind("click", function() { + $('#output').empty(); + commandCenter.getCommandNodes(function(items) { $('#output').append(items) }); + }).appendTo('#output'); + }); + getFeatures(connection.domain); } } @@ -100,7 +117,7 @@ $(document).ready(function () { }); $('#queryForm').bind('submit', function (event) { - Adhoc.checkFeatures("#output", $('#queryJID').val()); + getFeatures($('#queryJID').val()); event.preventDefault(); }); });