annotate mod_admin_web/admin_web/www_files/js/main.js @ 302:50abf9922e6e

mod_admin_web: Don't delete the menu
author Florian Zeitz <florob@babelmonkeys.de>
date Mon, 27 Dec 2010 04:24:34 +0100
parents b241c79a0eb7
children c152ab024d1a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
1 var BOSH_SERVICE = 'http://localhost:5280/http-bind/';
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
2 var show_log = false;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
3
301
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
4 Strophe.addNamespace('C2SPUBSUB', 'http://prosody.im/streams/c2s');
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
5 Strophe.addNamespace('S2SPUBSUB', 'http://prosody.im/streams/s2s');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
6 Strophe.addNamespace('PUBSUB', 'http://jabber.org/protocol/pubsub');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
7 Strophe.addNamespace('CAPS', 'http://jabber.org/protocol/caps');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
8
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
9 var localJID = null;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
10 var connection = null;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
11
292
a9e69088e678 mod_adhoc_web: Put pubsubHost into js from lua. Compat with util.pubsub changes
Florian Zeitz <florob@babelmonkeys.de>
parents: 288
diff changeset
12 var pubsubHost = '%PUBSUBHOST%';
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
13
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
14 function log(msg) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
15 var entry = $('<div></div>').append(document.createTextNode(msg));
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
16 $('#log').append(entry);
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
17 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
18
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
19 function rawInput(data) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
20 log('RECV: ' + data);
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
21 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
22
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
23 function rawOutput(data) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
24 log('SENT: ' + data);
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
25 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
26
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
27 function _cbNewS2S(e) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
28 var items, retract, id, jid;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
29 items = e.getElementsByTagName('item');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
30 for (i = 0; i < items.length; i++) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
31 id = items[i].attributes['id'].value;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
32 jid = items[i].getElementsByTagName('session')[0].attributes['jid'].value;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
33 if (items[i].getElementsByTagName('out')[0]) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
34 $('#s2sout').append('<li id="' + id + '">' + jid + '</li>');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
35 } else {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
36 $('#s2sin').append('<li id="' + id + '">' + jid + '</li>');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
37 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
38 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
39 retract = e.getElementsByTagName('retract')[0];
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
40 if (retract) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
41 id = retract.attributes['id'].value;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
42 $('#' + id).remove();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
43 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
44 return true;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
45 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
46
301
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
47 function _cbNewC2S(e) {
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
48 var items, retract, id, jid;
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
49 items = e.getElementsByTagName('item');
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
50 for (i = 0; i < items.length; i++) {
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
51 id = items[i].attributes['id'].value;
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
52 jid = items[i].getElementsByTagName('session')[0].attributes['jid'].value;
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
53 $('#c2s').append('<li id="' + id + '">' + jid + '</li>');
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
54 }
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
55 retract = e.getElementsByTagName('retract')[0];
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
56 if (retract) {
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
57 id = retract.attributes['id'].value;
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
58 $('#' + id).remove();
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
59 }
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
60 return true;
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
61 }
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
62
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
63 function _cbPubSub(e) {
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
64 var node = e.getElementsByTagName('items')[0].attributes['node'].value;
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
65 if (node == Strophe.NS.C2SPUBSUB) {
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
66 _cbNewC2S(e);
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
67 } else if (node == Strophe.NS.S2SPUBSUB) {
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
68 _cbNewS2S(e);
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
69 }
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
70
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
71 return true;
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
72 }
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
73
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
74 function onConnect(status) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
75 if (status == Strophe.Status.CONNECTING) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
76 log('Strophe is connecting.');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
77 } else if (status == Strophe.Status.CONNFAIL) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
78 log('Strophe failed to connect.');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
79 showConnect();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
80 } else if (status == Strophe.Status.DISCONNECTING) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
81 log('Strophe is disconnecting.');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
82 } else if (status == Strophe.Status.DISCONNECTED) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
83 log('Strophe is disconnected.');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
84 showConnect();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
85 } else if (status == Strophe.Status.AUTHFAIL) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
86 log('Authentication failed');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
87 if (connection) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
88 connection.disconnect();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
89 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
90 } else if (status == Strophe.Status.CONNECTED) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
91 log('Strophe is connected.');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
92 showDisconnect();
297
a70284e01453 mod_admin_web: Add support for calling adhoc commands
Florian Zeitz <florob@babelmonkeys.de>
parents: 294
diff changeset
93 Adhoc.checkFeatures('#adhoc', connection.domain);
301
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
94 connection.addHandler(_cbPubSub, Strophe.NS.PUBSUB + '#event', 'message');
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
95 connection.send($iq({to: pubsubHost, type: 'set', id: connection.getUniqueId()}).c('pubsub', {xmlns: Strophe.NS.PUBSUB})
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
96 .c('subscribe', {node: Strophe.NS.C2SPUBSUB, jid: connection.jid}));
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
97 connection.send($iq({to: pubsubHost, type: 'set', id: connection.getUniqueId()}).c('pubsub', {xmlns: Strophe.NS.PUBSUB})
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
98 .c('subscribe', {node: Strophe.NS.S2SPUBSUB, jid: connection.jid}));
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
99 connection.sendIQ($iq({to: pubsubHost, type: 'get', id: connection.getUniqueId()}).c('pubsub', {xmlns: Strophe.NS.PUBSUB})
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
100 .c('items', {node: Strophe.NS.S2SPUBSUB}), _cbNewS2S);
301
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
101 connection.sendIQ($iq({to: pubsubHost, type: 'get', id: connection.getUniqueId()}).c('pubsub', {xmlns: Strophe.NS.PUBSUB})
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
102 .c('items', {node: Strophe.NS.C2SPUBSUB}), _cbNewC2S);
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
103
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
104 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
105 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
106
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
107 function showConnect() {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
108 var jid = $('#jid');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
109 var pass = $('#pass');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
110 var button = $('#connect').get(0);
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
111
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
112 button.value = 'connect';
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
113 pass.show();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
114 jid.show();
294
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
115 $('#menu').hide();
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
116 $('#adhoc').hide();
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
117 $('#s2sList').hide();
301
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
118 $('#c2sList').hide();
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
119 $('#cred label').show();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
120 $('#cred br').show();
302
50abf9922e6e mod_admin_web: Don't delete the menu
Florian Zeitz <florob@babelmonkeys.de>
parents: 301
diff changeset
121 $('#s2sin').empty();
50abf9922e6e mod_admin_web: Don't delete the menu
Florian Zeitz <florob@babelmonkeys.de>
parents: 301
diff changeset
122 $('#s2sout').empty();
50abf9922e6e mod_admin_web: Don't delete the menu
Florian Zeitz <florob@babelmonkeys.de>
parents: 301
diff changeset
123 $('#c2s').empty();
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
124 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
125
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
126 function showDisconnect() {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
127 var jid = $('#jid');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
128 var pass = $('#pass');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
129 var button = $('#connect').get(0);
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
130
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
131 button.value = 'disconnect';
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
132 pass.hide();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
133 jid.hide();
294
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
134 $('#menu').show();
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
135 $('#adhoc').show();
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
136 $('#cred label').hide();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
137 $('#cred br').hide();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
138 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
139
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
140 $(document).ready(function () {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
141 connection = new Strophe.Connection(BOSH_SERVICE);
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
142 if (show_log) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
143 $('#log_container').show();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
144 connection.rawInput = rawInput;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
145 connection.rawOutput = rawOutput;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
146 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
147
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
148 $("#log_toggle").click(function () {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
149 $("#log").toggle();
294
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
150 });
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
151
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
152 $('#cred').bind('submit', function (event) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
153 var button = $('#connect').get(0);
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
154 var jid = $('#jid');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
155 var pass = $('#pass');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
156 localJID = jid.get(0).value;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
157
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
158 if (button.value == 'connect') {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
159 $('#log').empty();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
160 connection.connect(localJID,
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
161 pass.get(0).value,
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
162 onConnect);
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
163 } else {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
164 connection.disconnect();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
165 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
166 event.preventDefault();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
167 });
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
168
294
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
169 $('#adhocMenu').click(function () {
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
170 $('#s2sList').slideUp();
301
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
171 $('#c2sList').slideUp();
294
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
172 $('#adhoc').slideDown();
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
173 event.preventDefault();
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
174 });
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
175
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
176 $('#serverMenu').click(function () {
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
177 $('#adhoc').slideUp();
301
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
178 $('#c2sList').slideUp();
294
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
179 $('#s2sList').slideDown();
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
180 event.preventDefault();
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
181 });
301
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
182
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
183 $('#clientMenu').click(function () {
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
184 $('#adhoc').slideUp();
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
185 $('#s2sList').slideUp();
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
186 $('#c2sList').slideDown();
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
187 event.preventDefault();
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
188 });
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
189
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
190 });
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
191
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
192 window.onunload = window.onbeforeunload = function() {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
193 if (connection) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
194 connection.disconnect();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
195 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
196 }