blob: 7aa450a51ae0b62de1881195f0f83f5964eeb73f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/**
* ojsxc v0.7.1 - 2014-03-18
*
* Copyright (c) 2014 Klaus Herberth <klaus@jsxc.org> <br>
* Released under the MIT license
*
* Please see http://jsxc.org/
*
* @author Klaus Herberth <klaus@jsxc.org>
* @version 0.7.1
*/
$(document).ready(function() {
$('#ojsxc').submit(function(event) {
event.preventDefault();
//clear area
$('#ojsxc .msg').html(' ');
var post = $(this).serialize();
var status = $('<div/>').html('<img src="' + jsxc.options.root +'/img/loading.gif" alt="wait" width="16px" height="16px" />');
var statusBosh = status.clone().html(status.html() + " Testing BOSH Server...");
$('#ojsxc .msg').append(statusBosh);
var rid = jsxc.storage.getItem('rid') || '123456';
var xmppDomain = $('#xmppDomain').val();
var fail = function() {
statusBosh.addClass('jsxc_fail').text('BOSH server NOT reachable. Please beware of the SOP. If your XMPP server doesn\'t reside on the same host as your OwnCloud, use the Apache ProxyRequest or modify the CSP by defining "custom_csp_policy" in OwnCloud\'s config.php.');
};
$.post($('#boshUrl').val(), "<body rid='"+rid+"' xmlns='http://jabber.org/protocol/httpbind' to='"+xmppDomain+"' xml:lang='en' wait='60' hold='1' content='text/xml; charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh'/>").done(function(stanza) {
var body = $(stanza).find('body[xmlns="http://jabber.org/protocol/httpbind"]');
var condition = (body)? body.attr('condition'): null;
if(body.length > 0 && condition != 'internal-server-error'){
statusBosh.addClass('jsxc_success').text('BOSH Server reachable.');
} else {
fail();
if(condition == 'internal-server-error'){
statusBosh.html(statusBosh.text() + ' <br /><br /><b>Error: </b>'+body.text());
}
}
}).fail(fail);
var statusSet = status.clone().html(status.html() + " Saving...");
$('#ojsxc .msg').append(statusSet);
$.post(OC.filePath('ojsxc', 'ajax', 'setsettings.php'), post, function(data) {
if (data)
statusSet.addClass('jsxc_success').text('Settings saved.');
else
statusSet.addClass('jsxc_fail').text('Error!');
});
});
});
|