Mercurial > prosody-modules
annotate mod_admin_web/admin_web/www_files/js/main.js @ 318:84caab2bc02c
mod_data_access: New plugin providing a HTTP interface to Prosodys datamanager
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 19 Jan 2011 20:18:38 +0100 |
parents | 4f78f5020aa9 |
children | ba2e78661ea8 |
rev | line source |
---|---|
307
eeef1fa57f88
mod_admin_web: Specify only directory as bosh service, so it (normally) doesn't need changing (Thanks Zash)
Florian Zeitz <florob@babelmonkeys.de>
parents:
306
diff
changeset
|
1 var BOSH_SERVICE = '/http-bind/'; |
317
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
2 var show_log = true; |
288
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
3 |
317
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
4 Strophe.addNamespace('C2SSTREAM', 'http://prosody.im/streams/c2s'); |
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
5 Strophe.addNamespace('S2SSTREAM', 'http://prosody.im/streams/s2s'); |
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
6 Strophe.addNamespace('ADMINSUB', 'http://prosody.im/adminsub'); |
288
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 |
317
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
12 var adminsubHost = '%ADMINSUBHOST%'; |
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>'); |
317
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
35 if (items[i].getElementsByTagName('encrypted')[0]) { |
306
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 } |
317
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
38 if (items[i].getElementsByTagName('compressed')[0]) { |
306
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>'); |
317
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
63 if (items[i].getElementsByTagName('encrypted')[0]) { |
306
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 } |
317
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
66 if (items[i].getElementsByTagName('compressed')[0]) { |
306
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 |
317
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
79 function _cbAdminSub(e) { |
301
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; |
317
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
81 if (node == Strophe.NS.C2SSTREAM) { |
301
b241c79a0eb7
mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents:
297
diff
changeset
|
82 _cbNewC2S(e); |
317
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
83 } else if (node == Strophe.NS.S2SSTREAM) { |
301
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(); |
317
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
109 connection.addHandler(_cbAdminSub, Strophe.NS.ADMINSUB + '#event', 'message'); |
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
110 connection.send($iq({to: adminsubHost, type: 'set', id: connection.getUniqueId()}).c('adminsub', {xmlns: Strophe.NS.ADMINSUB}) |
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
111 .c('subscribe', {node: Strophe.NS.C2SSTREAM})); |
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
112 connection.send($iq({to: adminsubHost, type: 'set', id: connection.getUniqueId()}).c('adminsub', {xmlns: Strophe.NS.ADMINSUB}) |
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
113 .c('subscribe', {node: Strophe.NS.S2SSTREAM})); |
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
114 connection.sendIQ($iq({to: adminsubHost, type: 'get', id: connection.getUniqueId()}).c('adminsub', {xmlns: Strophe.NS.ADMINSUB}) |
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
115 .c('items', {node: Strophe.NS.S2SSTREAM}), _cbNewS2S); |
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
116 connection.sendIQ($iq({to: adminsubHost, type: 'get', id: connection.getUniqueId()}).c('adminsub', {xmlns: Strophe.NS.ADMINSUB}) |
4f78f5020aa9
mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents:
308
diff
changeset
|
117 .c('items', {node: Strophe.NS.C2SSTREAM}), _cbNewC2S); |
297
a70284e01453
mod_admin_web: Add support for calling adhoc commands
Florian Zeitz <florob@babelmonkeys.de>
parents:
294
diff
changeset
|
118 Adhoc.checkFeatures('#adhoc', connection.domain); |
288
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
119 } |
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 function showConnect() { |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
123 var jid = $('#jid'); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
124 var pass = $('#pass'); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
125 var button = $('#connect').get(0); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
126 |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
127 button.value = 'connect'; |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
128 pass.show(); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
129 jid.show(); |
294
5a619d6045a8
mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents:
292
diff
changeset
|
130 $('#menu').hide(); |
5a619d6045a8
mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents:
292
diff
changeset
|
131 $('#adhoc').hide(); |
5a619d6045a8
mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents:
292
diff
changeset
|
132 $('#s2sList').hide(); |
301
b241c79a0eb7
mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents:
297
diff
changeset
|
133 $('#c2sList').hide(); |
288
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
134 $('#cred label').show(); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
135 $('#cred br').show(); |
302
50abf9922e6e
mod_admin_web: Don't delete the menu
Florian Zeitz <florob@babelmonkeys.de>
parents:
301
diff
changeset
|
136 $('#s2sin').empty(); |
50abf9922e6e
mod_admin_web: Don't delete the menu
Florian Zeitz <florob@babelmonkeys.de>
parents:
301
diff
changeset
|
137 $('#s2sout').empty(); |
50abf9922e6e
mod_admin_web: Don't delete the menu
Florian Zeitz <florob@babelmonkeys.de>
parents:
301
diff
changeset
|
138 $('#c2s').empty(); |
288
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 |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
141 function showDisconnect() { |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
142 var jid = $('#jid'); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
143 var pass = $('#pass'); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
144 var button = $('#connect').get(0); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
145 |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
146 button.value = 'disconnect'; |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
147 pass.hide(); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
148 jid.hide(); |
294
5a619d6045a8
mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents:
292
diff
changeset
|
149 $('#menu').show(); |
5a619d6045a8
mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents:
292
diff
changeset
|
150 $('#adhoc').show(); |
288
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
151 $('#cred label').hide(); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
152 $('#cred br').hide(); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
153 } |
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 $(document).ready(function () { |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
156 connection = new Strophe.Connection(BOSH_SERVICE); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
157 if (show_log) { |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
158 $('#log_container').show(); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
159 connection.rawInput = rawInput; |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
160 connection.rawOutput = rawOutput; |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
161 } |
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 $("#log_toggle").click(function () { |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
164 $("#log").toggle(); |
294
5a619d6045a8
mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents:
292
diff
changeset
|
165 }); |
288
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
166 |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
167 $('#cred').bind('submit', function (event) { |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
168 var button = $('#connect').get(0); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
169 var jid = $('#jid'); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
170 var pass = $('#pass'); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
171 localJID = jid.get(0).value; |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
172 |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
173 if (button.value == 'connect') { |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
174 $('#log').empty(); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
175 connection.connect(localJID, |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
176 pass.get(0).value, |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
177 onConnect); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
178 } else { |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
179 connection.disconnect(); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
180 } |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
181 event.preventDefault(); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
182 }); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
183 |
308
f406e300d709
mod_admin_web: Add missing argument
Florian Zeitz <florob@babelmonkeys.de>
parents:
307
diff
changeset
|
184 $('#adhocMenu').click(function (event) { |
294
5a619d6045a8
mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents:
292
diff
changeset
|
185 $('#s2sList').slideUp(); |
301
b241c79a0eb7
mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents:
297
diff
changeset
|
186 $('#c2sList').slideUp(); |
294
5a619d6045a8
mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents:
292
diff
changeset
|
187 $('#adhoc').slideDown(); |
5a619d6045a8
mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents:
292
diff
changeset
|
188 event.preventDefault(); |
5a619d6045a8
mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents:
292
diff
changeset
|
189 }); |
5a619d6045a8
mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents:
292
diff
changeset
|
190 |
308
f406e300d709
mod_admin_web: Add missing argument
Florian Zeitz <florob@babelmonkeys.de>
parents:
307
diff
changeset
|
191 $('#serverMenu').click(function (event) { |
294
5a619d6045a8
mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents:
292
diff
changeset
|
192 $('#adhoc').slideUp(); |
301
b241c79a0eb7
mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents:
297
diff
changeset
|
193 $('#c2sList').slideUp(); |
294
5a619d6045a8
mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents:
292
diff
changeset
|
194 $('#s2sList').slideDown(); |
5a619d6045a8
mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents:
292
diff
changeset
|
195 event.preventDefault(); |
5a619d6045a8
mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents:
292
diff
changeset
|
196 }); |
301
b241c79a0eb7
mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents:
297
diff
changeset
|
197 |
308
f406e300d709
mod_admin_web: Add missing argument
Florian Zeitz <florob@babelmonkeys.de>
parents:
307
diff
changeset
|
198 $('#clientMenu').click(function (event) { |
301
b241c79a0eb7
mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents:
297
diff
changeset
|
199 $('#adhoc').slideUp(); |
b241c79a0eb7
mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents:
297
diff
changeset
|
200 $('#s2sList').slideUp(); |
b241c79a0eb7
mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents:
297
diff
changeset
|
201 $('#c2sList').slideDown(); |
b241c79a0eb7
mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents:
297
diff
changeset
|
202 event.preventDefault(); |
b241c79a0eb7
mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents:
297
diff
changeset
|
203 }); |
b241c79a0eb7
mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents:
297
diff
changeset
|
204 |
288
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
205 }); |
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 window.onunload = window.onbeforeunload = function() { |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
208 if (connection) { |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
209 connection.disconnect(); |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
210 } |
9233d7ee3c09
mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
211 } |