1 var BOSH_SERVICE = 'http://localhost:5280/http-bind/';
7 var commandCenter = null;
10 var entry = $('<div></div>').append(document.createTextNode(msg));
11 $('#log').append(entry);
14 function rawInput(data) {
18 function rawOutput(data) {
22 function getFeatures(jid) {
24 cb = function(result) { /* Callback */
25 commandCenter.getCommandNodes(function(items) { $('#output').empty(); $('#output').append(items) });
27 ecb = function(result) { /* Errback */
28 $('#output').append("<p>" + jid + " does NOT support AdHoc commands</p>");
30 commandCenter.checkFeatures(jid, cb, ecb);
33 function onConnect(status) {
34 if (status == Strophe.Status.CONNECTING) {
35 log('Strophe is connecting.');
36 } else if (status == Strophe.Status.CONNFAIL) {
37 log('Strophe failed to connect.');
39 } else if (status == Strophe.Status.DISCONNECTING) {
40 log('Strophe is disconnecting.');
41 } else if (status == Strophe.Status.DISCONNECTED) {
42 log('Strophe is disconnected.');
44 } else if (status == Strophe.Status.AUTHFAIL) {
45 log('Authentication failed');
47 connection.disconnect();
49 } else if (status == Strophe.Status.CONNECTED) {
50 log('Strophe is connected.');
51 $('#queryJID').val(connection.domain);
53 commandCenter = new Adhoc("#output", function() {
54 $("<input type='button' value='Start over'/>").bind("click", function() {
56 commandCenter.getCommandNodes(function(items) { $('#output').append(items) });
57 }).appendTo('#output');
59 getFeatures(connection.domain);
63 function showConnect() {
65 var pass = $('#pass');
66 var button = $('#connect').get(0);
68 button.value = 'connect';
72 $('#cred label').show();
77 function showDisconnect() {
79 var pass = $('#pass');
80 var button = $('#connect').get(0);
82 button.value = 'disconnect';
85 $('#cred label').hide();
89 $(document).ready(function () {
90 connection = new Strophe.Connection(BOSH_SERVICE);
92 $('#log_container').show();
93 connection.rawInput = rawInput;
94 connection.rawOutput = rawOutput;
97 $("#log_toggle").click(function () {
101 $('#cred').bind('submit', function (event) {
102 var button = $('#connect').get(0);
104 var pass = $('#pass');
105 localJID = jid.get(0).value;
107 if (button.value == 'connect') {
110 connection.connect(localJID,
114 connection.disconnect();
116 event.preventDefault();
119 $('#queryForm').bind('submit', function (event) {
120 getFeatures($('#queryJID').val());
121 event.preventDefault();
125 window.onunload = window.onbeforeunload = function() {
127 connection.disconnect();