annotate mod_admin_web/admin_web/www_files/js/main.js @ 306:c152ab024d1a

mod_admin_web: Show whether connection is encrypted/compressed
author Florian Zeitz <florob@babelmonkeys.de>
date Mon, 27 Dec 2010 21:34:41 +0100
parents 50abf9922e6e
children eeef1fa57f88
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) {
306
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
28 var items, entry, retract, id, jid;
288
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;
306
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
33
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
34 entry = $('<li id="' + id + '">' + jid + '</li>');
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
35 if (e.getElementsByTagName('encrypted')[0]) {
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
36 entry.append('<img src="images/encrypted.png" title="encrypted" alt=" (encrypted)" />');
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
37 }
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
38 if (e.getElementsByTagName('compressed')[0]) {
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
39 entry.append('<img src="images/compressed.png" title="compressed" alt=" (compressed)" />');
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
40 }
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
41
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
42 if (items[i].getElementsByTagName('out')[0]) {
306
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
43 entry.appendTo('#s2sout');
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
44 } else {
306
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
45 entry.appendTo('#s2sin');
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
46 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
47 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
48 retract = e.getElementsByTagName('retract')[0];
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
49 if (retract) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
50 id = retract.attributes['id'].value;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
51 $('#' + id).remove();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
52 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
53 return true;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
54 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
55
301
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
56 function _cbNewC2S(e) {
306
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
57 var items, entry, retract, id, jid;
301
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
58 items = e.getElementsByTagName('item');
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
59 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
60 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
61 jid = items[i].getElementsByTagName('session')[0].attributes['jid'].value;
306
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
62 entry = $('<li id="' + id + '">' + jid + '</li>');
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
63 if (e.getElementsByTagName('encrypted')[0]) {
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
64 entry.append('<img src="images/encrypted.png" title="encrypted" alt=" (encrypted)" />');
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
65 }
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
66 if (e.getElementsByTagName('compressed')[0]) {
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
67 entry.append('<img src="images/compressed.png" title="compressed" alt=" (compressed)" />');
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
68 }
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
69 entry.appendTo('#c2s');
301
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 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
72 if (retract) {
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
73 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
74 $('#' + id).remove();
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
75 }
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
76 return true;
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
77 }
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
78
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
79 function _cbPubSub(e) {
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
80 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
81 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
82 _cbNewC2S(e);
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
83 } 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
84 _cbNewS2S(e);
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
85 }
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
86
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
87 return true;
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
88 }
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
89
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
90 function onConnect(status) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
91 if (status == Strophe.Status.CONNECTING) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
92 log('Strophe is connecting.');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
93 } else if (status == Strophe.Status.CONNFAIL) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
94 log('Strophe failed to connect.');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
95 showConnect();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
96 } else if (status == Strophe.Status.DISCONNECTING) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
97 log('Strophe is disconnecting.');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
98 } else if (status == Strophe.Status.DISCONNECTED) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
99 log('Strophe is disconnected.');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
100 showConnect();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
101 } else if (status == Strophe.Status.AUTHFAIL) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
102 log('Authentication failed');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
103 if (connection) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
104 connection.disconnect();
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 } else if (status == Strophe.Status.CONNECTED) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
107 log('Strophe is connected.');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
108 showDisconnect();
297
a70284e01453 mod_admin_web: Add support for calling adhoc commands
Florian Zeitz <florob@babelmonkeys.de>
parents: 294
diff changeset
109 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
110 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
111 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
112 .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
113 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
114 .c('subscribe', {node: Strophe.NS.S2SPUBSUB, jid: connection.jid}));
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
115 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
116 .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
117 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
118 .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
119
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
120 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
121 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
122
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
123 function showConnect() {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
124 var jid = $('#jid');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
125 var pass = $('#pass');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
126 var button = $('#connect').get(0);
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
127
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
128 button.value = 'connect';
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
129 pass.show();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
130 jid.show();
294
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
131 $('#menu').hide();
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
132 $('#adhoc').hide();
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
133 $('#s2sList').hide();
301
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
134 $('#c2sList').hide();
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
135 $('#cred label').show();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
136 $('#cred br').show();
302
50abf9922e6e mod_admin_web: Don't delete the menu
Florian Zeitz <florob@babelmonkeys.de>
parents: 301
diff changeset
137 $('#s2sin').empty();
50abf9922e6e mod_admin_web: Don't delete the menu
Florian Zeitz <florob@babelmonkeys.de>
parents: 301
diff changeset
138 $('#s2sout').empty();
50abf9922e6e mod_admin_web: Don't delete the menu
Florian Zeitz <florob@babelmonkeys.de>
parents: 301
diff changeset
139 $('#c2s').empty();
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
140 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
141
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
142 function showDisconnect() {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
143 var jid = $('#jid');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
144 var pass = $('#pass');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
145 var button = $('#connect').get(0);
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 button.value = 'disconnect';
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
148 pass.hide();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
149 jid.hide();
294
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
150 $('#menu').show();
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
151 $('#adhoc').show();
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
152 $('#cred label').hide();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
153 $('#cred br').hide();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
154 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
155
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
156 $(document).ready(function () {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
157 connection = new Strophe.Connection(BOSH_SERVICE);
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
158 if (show_log) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
159 $('#log_container').show();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
160 connection.rawInput = rawInput;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
161 connection.rawOutput = rawOutput;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
162 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
163
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
164 $("#log_toggle").click(function () {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
165 $("#log").toggle();
294
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
166 });
288
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 $('#cred').bind('submit', function (event) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
169 var button = $('#connect').get(0);
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
170 var jid = $('#jid');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
171 var pass = $('#pass');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
172 localJID = jid.get(0).value;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
173
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
174 if (button.value == 'connect') {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
175 $('#log').empty();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
176 connection.connect(localJID,
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
177 pass.get(0).value,
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
178 onConnect);
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
179 } else {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
180 connection.disconnect();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
181 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
182 event.preventDefault();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
183 });
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
184
294
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
185 $('#adhocMenu').click(function () {
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
186 $('#s2sList').slideUp();
301
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
187 $('#c2sList').slideUp();
294
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
188 $('#adhoc').slideDown();
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
189 event.preventDefault();
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
190 });
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
191
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
192 $('#serverMenu').click(function () {
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
193 $('#adhoc').slideUp();
301
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
194 $('#c2sList').slideUp();
294
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
195 $('#s2sList').slideDown();
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
196 event.preventDefault();
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
197 });
301
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
198
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
199 $('#clientMenu').click(function () {
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
200 $('#adhoc').slideUp();
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
201 $('#s2sList').slideUp();
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
202 $('#c2sList').slideDown();
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
203 event.preventDefault();
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
204 });
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
205
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
206 });
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
207
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
208 window.onunload = window.onbeforeunload = function() {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
209 if (connection) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
210 connection.disconnect();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
211 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
212 }