annotate mod_admin_web/admin_web/www_files/js/main.js @ 987:fabff75bfc3f

mod_smacks: If a hibernating session was destroyed before the timeout, don't destroy it again or say that it was resumed
author Kim Alvefur <zash@zash.se>
date Thu, 25 Apr 2013 17:34:30 +0200
parents 1d03dc7cf28f
children 7cba8be42d9e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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/';
319
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
2 var show_log = false;
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
319
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
12 var adminsubHost = null;
573
c9955858dc7e mod_adhoc_web: Redesign adhoc command pane
Florian Zeitz <florob@babelmonkeys.de>
parents: 547
diff changeset
13 var adhocControl = new Adhoc('#adhocDisplay', function() {});
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
14
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
15 function log(msg) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
16 var entry = $('<div></div>').append(document.createTextNode(msg));
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
17 $('#log').append(entry);
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
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
20 function rawInput(data) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
21 log('RECV: ' + data);
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
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
24 function rawOutput(data) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
25 log('SENT: ' + data);
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
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
28 function _cbNewS2S(e) {
396
8cb21ef24e5d mod_admin_web: Show S2S certificate validity
Florian Zeitz <florob@babelmonkeys.de>
parents: 334
diff changeset
29 var items, entry, tmp, retract, id, jid;
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
30 items = e.getElementsByTagName('item');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
31 for (i = 0; i < items.length; i++) {
614
40ab83736f6e mod_admin_web: Correctly access items in NamedNodeMaps
Florian Zeitz <florob@babelmonkeys.de>
parents: 584
diff changeset
32 id = items[i].attributes.getNamedItem('id').value;
40ab83736f6e mod_admin_web: Correctly access items in NamedNodeMaps
Florian Zeitz <florob@babelmonkeys.de>
parents: 584
diff changeset
33 jid = items[i].getElementsByTagName('session')[0].attributes.getNamedItem('jid').value;
306
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
34
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
35 entry = $('<li id="' + id + '">' + jid + '</li>');
396
8cb21ef24e5d mod_admin_web: Show S2S certificate validity
Florian Zeitz <florob@babelmonkeys.de>
parents: 334
diff changeset
36 if (tmp = items[i].getElementsByTagName('encrypted')[0]) {
8cb21ef24e5d mod_admin_web: Show S2S certificate validity
Florian Zeitz <florob@babelmonkeys.de>
parents: 334
diff changeset
37 if (tmp.getElementsByTagName('valid')[0]) {
8cb21ef24e5d mod_admin_web: Show S2S certificate validity
Florian Zeitz <florob@babelmonkeys.de>
parents: 334
diff changeset
38 entry.append('<img src="images/secure.png" title="encrypted (certificate valid)" alt=" (secure) (encrypted)" />');
8cb21ef24e5d mod_admin_web: Show S2S certificate validity
Florian Zeitz <florob@babelmonkeys.de>
parents: 334
diff changeset
39 } else {
8cb21ef24e5d mod_admin_web: Show S2S certificate validity
Florian Zeitz <florob@babelmonkeys.de>
parents: 334
diff changeset
40 entry.append('<img src="images/encrypted.png" title="encrypted (certificate invalid)" alt=" (encrypted)" />');
8cb21ef24e5d mod_admin_web: Show S2S certificate validity
Florian Zeitz <florob@babelmonkeys.de>
parents: 334
diff changeset
41 }
306
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
42 }
317
4f78f5020aa9 mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents: 308
diff changeset
43 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
44 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
45 }
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
46
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
47 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
48 entry.appendTo('#s2sout');
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
49 } else {
306
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
50 entry.appendTo('#s2sin');
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
51 }
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 retract = e.getElementsByTagName('retract')[0];
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
54 if (retract) {
614
40ab83736f6e mod_admin_web: Correctly access items in NamedNodeMaps
Florian Zeitz <florob@babelmonkeys.de>
parents: 584
diff changeset
55 id = retract.attributes.getNamedItem('id').value;
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
56 $('#' + id).remove();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
57 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
58 return true;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
59 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
60
301
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
61 function _cbNewC2S(e) {
306
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
62 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
63 items = e.getElementsByTagName('item');
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
64 for (i = 0; i < items.length; i++) {
614
40ab83736f6e mod_admin_web: Correctly access items in NamedNodeMaps
Florian Zeitz <florob@babelmonkeys.de>
parents: 584
diff changeset
65 id = items[i].attributes.getNamedItem('id').value;
40ab83736f6e mod_admin_web: Correctly access items in NamedNodeMaps
Florian Zeitz <florob@babelmonkeys.de>
parents: 584
diff changeset
66 jid = items[i].getElementsByTagName('session')[0].attributes.getNamedItem('jid').value;
306
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
67 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
68 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
69 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
70 }
317
4f78f5020aa9 mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents: 308
diff changeset
71 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
72 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
73 }
c152ab024d1a mod_admin_web: Show whether connection is encrypted/compressed
Florian Zeitz <florob@babelmonkeys.de>
parents: 302
diff changeset
74 entry.appendTo('#c2s');
301
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 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
77 if (retract) {
614
40ab83736f6e mod_admin_web: Correctly access items in NamedNodeMaps
Florian Zeitz <florob@babelmonkeys.de>
parents: 584
diff changeset
78 id = retract.attributes.getNamedItem('id').value;
301
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
79 $('#' + id).remove();
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
80 }
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
81 return true;
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
82 }
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
83
317
4f78f5020aa9 mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents: 308
diff changeset
84 function _cbAdminSub(e) {
614
40ab83736f6e mod_admin_web: Correctly access items in NamedNodeMaps
Florian Zeitz <florob@babelmonkeys.de>
parents: 584
diff changeset
85 var node = e.getElementsByTagName('items')[0].attributes.getNamedItem('node').value;
317
4f78f5020aa9 mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents: 308
diff changeset
86 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
87 _cbNewC2S(e);
317
4f78f5020aa9 mod_admin_web: Get rid of the mod_pubsub dependency
Florian Zeitz <florob@babelmonkeys.de>
parents: 308
diff changeset
88 } 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
89 _cbNewS2S(e);
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
90 }
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
91
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
92 return true;
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
93 }
b241c79a0eb7 mod_admin_web: Add a live view for C2S connections
Florian Zeitz <florob@babelmonkeys.de>
parents: 297
diff changeset
94
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
95 function onConnect(status) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
96 if (status == Strophe.Status.CONNECTING) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
97 log('Strophe is connecting.');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
98 } else if (status == Strophe.Status.CONNFAIL) {
915
1d03dc7cf28f mod_admin_web: Better error reporting
Florian Zeitz <florob@babelmonkeys.de>
parents: 914
diff changeset
99 alert('Connection failed (Wrong host?)');
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
100 log('Strophe failed to connect.');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
101 showConnect();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
102 } else if (status == Strophe.Status.DISCONNECTING) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
103 log('Strophe is disconnecting.');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
104 } else if (status == Strophe.Status.DISCONNECTED) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
105 log('Strophe is disconnected.');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
106 showConnect();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
107 } else if (status == Strophe.Status.AUTHFAIL) {
915
1d03dc7cf28f mod_admin_web: Better error reporting
Florian Zeitz <florob@babelmonkeys.de>
parents: 914
diff changeset
108 alert('Wrong username and/or password');
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
109 log('Authentication failed');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
110 if (connection) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
111 connection.disconnect();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
112 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
113 } else if (status == Strophe.Status.CONNECTED) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
114 log('Strophe is connected.');
319
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
115 connection.sendIQ($iq({to: connection.domain, type: 'get', id: connection.getUniqueId()}).c('adminsub', {xmlns: Strophe.NS.ADMINSUB})
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
116 .c('adminfor'), function(e) {
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
117 var items;
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
118 items = e.getElementsByTagName('item');
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
119 if (items.length == 0) {
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
120 alert("You are not an administrator");
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
121 connection.disconnect();
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
122 return false;
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
123 }
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
124 for (i = 0; i < items.length; i++) {
914
fa996cfec6da mod_admin_web: Default the host selection to the administrators domainpart
Florian Zeitz <florob@babelmonkeys.de>
parents: 614
diff changeset
125 var host = $(items[i]).text();
fa996cfec6da mod_admin_web: Default the host selection to the administrators domainpart
Florian Zeitz <florob@babelmonkeys.de>
parents: 614
diff changeset
126 if (host == Strophe.getDomainFromJid(connection.jid)) {
fa996cfec6da mod_admin_web: Default the host selection to the administrators domainpart
Florian Zeitz <florob@babelmonkeys.de>
parents: 614
diff changeset
127 $('#host').append('<option selected>' + host + '</option>');
fa996cfec6da mod_admin_web: Default the host selection to the administrators domainpart
Florian Zeitz <florob@babelmonkeys.de>
parents: 614
diff changeset
128 } else {
fa996cfec6da mod_admin_web: Default the host selection to the administrators domainpart
Florian Zeitz <florob@babelmonkeys.de>
parents: 614
diff changeset
129 $('#host').append('<option>' + host + '</option>');
fa996cfec6da mod_admin_web: Default the host selection to the administrators domainpart
Florian Zeitz <florob@babelmonkeys.de>
parents: 614
diff changeset
130 }
319
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
131 }
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
132 showDisconnect();
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
133 adminsubHost = $(items[0]).text();
573
c9955858dc7e mod_adhoc_web: Redesign adhoc command pane
Florian Zeitz <florob@babelmonkeys.de>
parents: 547
diff changeset
134 adhocControl.checkFeatures(adminsubHost,
584
1c2fc3b845f2 mod_admin_web: Clear commands in all cases new ones are loaded (thanks Maranda)
Florian Zeitz <florob@babelmonkeys.de>
parents: 574
diff changeset
135 function () { adhocControl.getCommandNodes(function (result) { $('#adhocDisplay').empty(); $('#adhocCommands').html(result); }) },
573
c9955858dc7e mod_adhoc_web: Redesign adhoc command pane
Florian Zeitz <florob@babelmonkeys.de>
parents: 547
diff changeset
136 function () { $('#adhocCommands').empty(); $('#adhocDisplay').html('<p>This host does not support commands</p>'); });
319
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
137 connection.addHandler(_cbAdminSub, Strophe.NS.ADMINSUB + '#event', 'message');
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
138 connection.send($iq({to: adminsubHost, type: 'set', id: connection.getUniqueId()}).c('adminsub', {xmlns: Strophe.NS.ADMINSUB})
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
139 .c('subscribe', {node: Strophe.NS.C2SSTREAM}));
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
140 connection.send($iq({to: adminsubHost, type: 'set', id: connection.getUniqueId()}).c('adminsub', {xmlns: Strophe.NS.ADMINSUB})
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
141 .c('subscribe', {node: Strophe.NS.S2SSTREAM}));
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
142 connection.sendIQ($iq({to: adminsubHost, type: 'get', id: connection.getUniqueId()}).c('adminsub', {xmlns: Strophe.NS.ADMINSUB})
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
143 .c('items', {node: Strophe.NS.S2SSTREAM}), _cbNewS2S);
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
144 connection.sendIQ($iq({to: adminsubHost, type: 'get', id: connection.getUniqueId()}).c('adminsub', {xmlns: Strophe.NS.ADMINSUB})
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
145 .c('items', {node: Strophe.NS.C2SSTREAM}), _cbNewC2S);
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
146 });
288
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 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
149
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
150 function showConnect() {
539
99465bbfa205 First pass of web-admin redesign
Florian Zeitz <florob@babelmonkeys.de>
parents: 396
diff changeset
151 $('#login').show();
294
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
152 $('#menu').hide();
539
99465bbfa205 First pass of web-admin redesign
Florian Zeitz <florob@babelmonkeys.de>
parents: 396
diff changeset
153 $('#main').hide();
302
50abf9922e6e mod_admin_web: Don't delete the menu
Florian Zeitz <florob@babelmonkeys.de>
parents: 301
diff changeset
154 $('#s2sin').empty();
50abf9922e6e mod_admin_web: Don't delete the menu
Florian Zeitz <florob@babelmonkeys.de>
parents: 301
diff changeset
155 $('#s2sout').empty();
50abf9922e6e mod_admin_web: Don't delete the menu
Florian Zeitz <florob@babelmonkeys.de>
parents: 301
diff changeset
156 $('#c2s').empty();
319
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
157 $('#host').empty();
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
158 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
159
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
160 function showDisconnect() {
319
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
161 $('#s2sList').hide();
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
162 $('#c2sList').hide();
539
99465bbfa205 First pass of web-admin redesign
Florian Zeitz <florob@babelmonkeys.de>
parents: 396
diff changeset
163 $('#login').hide();
99465bbfa205 First pass of web-admin redesign
Florian Zeitz <florob@babelmonkeys.de>
parents: 396
diff changeset
164
99465bbfa205 First pass of web-admin redesign
Florian Zeitz <florob@babelmonkeys.de>
parents: 396
diff changeset
165 $('#menu').show();
99465bbfa205 First pass of web-admin redesign
Florian Zeitz <florob@babelmonkeys.de>
parents: 396
diff changeset
166 $('#main').show();
99465bbfa205 First pass of web-admin redesign
Florian Zeitz <florob@babelmonkeys.de>
parents: 396
diff changeset
167 $('#adhoc').show();
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
168 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
169
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
170 $(document).ready(function () {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
171 connection = new Strophe.Connection(BOSH_SERVICE);
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
172 if (show_log) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
173 $('#log_container').show();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
174 connection.rawInput = rawInput;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
175 connection.rawOutput = rawOutput;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
176 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
177
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
178 $("#log_toggle").click(function () {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
179 $("#log").toggle();
294
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
180 });
288
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 $('#cred').bind('submit', function (event) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
183 var button = $('#connect').get(0);
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
184 var jid = $('#jid');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
185 var pass = $('#pass');
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
186 localJID = jid.get(0).value;
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
187
539
99465bbfa205 First pass of web-admin redesign
Florian Zeitz <florob@babelmonkeys.de>
parents: 396
diff changeset
188 $('#log').empty();
99465bbfa205 First pass of web-admin redesign
Florian Zeitz <florob@babelmonkeys.de>
parents: 396
diff changeset
189 connection.connect(localJID, pass.get(0).value, onConnect);
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
190 event.preventDefault();
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
539
99465bbfa205 First pass of web-admin redesign
Florian Zeitz <florob@babelmonkeys.de>
parents: 396
diff changeset
193 $('#logout').click(function (event) {
99465bbfa205 First pass of web-admin redesign
Florian Zeitz <florob@babelmonkeys.de>
parents: 396
diff changeset
194 connection.disconnect();
99465bbfa205 First pass of web-admin redesign
Florian Zeitz <florob@babelmonkeys.de>
parents: 396
diff changeset
195 event.preventDefault();
99465bbfa205 First pass of web-admin redesign
Florian Zeitz <florob@babelmonkeys.de>
parents: 396
diff changeset
196 });
99465bbfa205 First pass of web-admin redesign
Florian Zeitz <florob@babelmonkeys.de>
parents: 396
diff changeset
197
547
f0ef6e285d69 mod_adhoc_web: fade instead of scrolling
Florian Zeitz <florob@babelmonkeys.de>
parents: 539
diff changeset
198 $('#adhocMenu, #serverMenu, #clientMenu').click(function (event) {
294
5a619d6045a8 mod_admin_web: Prepare for adding more features
Florian Zeitz <florob@babelmonkeys.de>
parents: 292
diff changeset
199 event.preventDefault();
547
f0ef6e285d69 mod_adhoc_web: fade instead of scrolling
Florian Zeitz <florob@babelmonkeys.de>
parents: 539
diff changeset
200 var tab = $(this).attr('href');
f0ef6e285d69 mod_adhoc_web: fade instead of scrolling
Florian Zeitz <florob@babelmonkeys.de>
parents: 539
diff changeset
201 $('#main > div').hide();
f0ef6e285d69 mod_adhoc_web: fade instead of scrolling
Florian Zeitz <florob@babelmonkeys.de>
parents: 539
diff changeset
202 $(tab).fadeIn('fast');
301
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
319
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
205 $('#host').bind('change', function (event) {
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
206 connection.send($iq({to: adminsubHost, type: 'set', id: connection.getUniqueId()}).c('adminsub', {xmlns: Strophe.NS.ADMINSUB})
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
207 .c('unsubscribe', {node: Strophe.NS.C2SSTREAM}));
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
208 connection.send($iq({to: adminsubHost, type: 'set', id: connection.getUniqueId()}).c('adminsub', {xmlns: Strophe.NS.ADMINSUB})
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
209 .c('unsubscribe', {node: Strophe.NS.S2SSTREAM}));
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
210 adminsubHost = $(this).val();
573
c9955858dc7e mod_adhoc_web: Redesign adhoc command pane
Florian Zeitz <florob@babelmonkeys.de>
parents: 547
diff changeset
211 adhocControl.checkFeatures(adminsubHost,
574
950e23318bbc mod_admin_web: Replace command list instead of appending
Florian Zeitz <florob@babelmonkeys.de>
parents: 573
diff changeset
212 function () { adhocControl.getCommandNodes(function (result) { $('#adhocDisplay').empty(); $('#adhocCommands').html(result); }) },
573
c9955858dc7e mod_adhoc_web: Redesign adhoc command pane
Florian Zeitz <florob@babelmonkeys.de>
parents: 547
diff changeset
213 function () { $('#adhocCommands').empty(); $('#adhocDisplay').html('<p>This host does not support commands</p>'); });
319
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
214 $('#s2sin').empty();
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
215 $('#s2sout').empty();
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
216 $('#c2s').empty();
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
217 connection.send($iq({to: adminsubHost, type: 'set', id: connection.getUniqueId()}).c('adminsub', {xmlns: Strophe.NS.ADMINSUB})
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
218 .c('subscribe', {node: Strophe.NS.C2SSTREAM}));
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
219 connection.send($iq({to: adminsubHost, type: 'set', id: connection.getUniqueId()}).c('adminsub', {xmlns: Strophe.NS.ADMINSUB})
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
220 .c('subscribe', {node: Strophe.NS.S2SSTREAM}));
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
221 connection.sendIQ($iq({to: adminsubHost, type: 'get', id: connection.getUniqueId()}).c('adminsub', {xmlns: Strophe.NS.ADMINSUB})
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
222 .c('items', {node: Strophe.NS.S2SSTREAM}), _cbNewS2S);
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
223 connection.sendIQ($iq({to: adminsubHost, type: 'get', id: connection.getUniqueId()}).c('adminsub', {xmlns: Strophe.NS.ADMINSUB})
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
224 .c('items', {node: Strophe.NS.C2SSTREAM}), _cbNewC2S);
ba2e78661ea8 mod_admin_web: Make module global. Host to administrate is now chooseable
Florian Zeitz <florob@babelmonkeys.de>
parents: 317
diff changeset
225 });
288
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
226 });
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
227
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
228 window.onunload = window.onbeforeunload = function() {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
229 if (connection) {
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
230 connection.disconnect();
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
231 }
9233d7ee3c09 mod_admin_web: Initial PoC commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
232 }