-
Notifications
You must be signed in to change notification settings - Fork 28
/
carddav_settings.js
88 lines (77 loc) · 2.75 KB
/
carddav_settings.js
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* Roundcube CardDAV addressbook extension
*
* @author Christian Putzke <[email protected]>
* @copyright Christian Putzke @ Graviox Studios
* @since 12.09.2011
* @link http://www.graviox.de/
* @link https://twitter.com/graviox/
* @version 0.5.1
* @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*
*/
if (window.rcmail)
{
rcmail.addEventListener('init', function(evt)
{
var tab = $('<span>').attr('id', 'settingstabplugincarddav-server').addClass('tablink');
var button = $('<a>').attr('href', rcmail.env.comm_path+'&_action=plugin.carddav-server').
html(rcmail.gettext('settings_tab', 'carddav')).appendTo(tab);
rcmail.add_element(tab, 'tabs');
rcmail.addEventListener('plugin.carddav_server_message', carddav_server_message);
rcmail.register_command('plugin.carddav-server-save', carddav_server_add, true);
rcmail.register_command('plugin.carddav-server-delete', function(carddav_server_id)
{
rcmail.http_post(
'plugin.carddav-server-delete',
'_carddav_server_id=' + $.base64Encode(carddav_server_id),
rcmail.display_message(rcmail.gettext('settings_delete_loading', 'carddav'), 'loading')
);
}, true);
$('#_label').keypress(carddav_server_add_enter_event);
$('#_server_url').keypress(carddav_server_add_enter_event);
$('#_username').keypress(carddav_server_add_enter_event);
$('#_password').keypress(carddav_server_add_enter_event);
});
function carddav_server_add_enter_event(e)
{
if (e.keyCode == 13)
{
carddav_server_add();
}
};
function carddav_server_add()
{
var input_label = rcube_find_object('_label');
var input_url = rcube_find_object('_server_url');
var input_username = rcube_find_object('_username');
var input_password = rcube_find_object('_password');
var input_read_only = rcube_find_object('_read_only');
if (input_label.value == '' || input_url.value == '')
{
rcmail.display_message(rcmail.gettext('settings_empty_values', 'carddav'), 'error');
}
else
{
rcmail.http_post(
'plugin.carddav-server-save',
'_label=' + $.base64Encode(input_label.value) + '&_server_url=' + $.base64Encode(input_url.value) + '&_username=' + $.base64Encode(input_username.value) + '&_password=' + $.base64Encode(input_password.value) + '&_read_only=' + $.base64Encode(input_read_only.checked === true ? '1' : '0'),
rcmail.display_message(rcmail.gettext('settings_init_server', 'carddav'), 'loading')
);
}
}
function carddav_server_message(response)
{
if (response.check)
{
$('#carddav_server_list').slideUp();
$('#carddav_server_list').html(response.server_list);
$('#carddav_server_list').slideDown();
rcmail.display_message(response.message, 'confirmation');
}
else
{
rcmail.display_message(response.message, 'error');
}
}
}