1 <script type="text/javascript">
2 var ldap_server_select = document.getElementById('rcfmd_ldap_public_servers');
4 if (ldap_server_select) {
5 // attach event to ldap server drop down
6 ldap_server_select.onchange = function() {
7 updateLdapSearchFields(this);
11 // update the fields on page load
12 updateLdapSearchFields(ldap_server_select);
16 * function to change the attributes of the ldap server search fields select box
17 * this function is triggered by an onchange event in the server select box
19 function updateLdapSearchFields(element) {
21 // get the search fields select element
22 var search_fields = document.getElementById('rcfmd_ldap_public_search_field');
24 // get rid of the current options for the select
25 for (i = search_fields.length - 1; i>=0; i--)
26 search_fields.remove(i);
28 // get the array containing this servers search fields
29 var server_fields = rcmail.env[element.value + '_search_fields'];
31 // add a new option for each of the possible search fields for the selected server
32 for (i = 0; i < server_fields.length; i++) {
34 // the last array value is for fuzzy search, so skip that one
35 if (i < (server_fields.length - 1)) {
36 var new_option = document.createElement('option');
37 new_option.text = server_fields[i][0];
38 new_option.value = server_fields[i][1];
40 // standards compliant browsers
42 search_fields.add(new_option, null);
44 // for the standards challenged one...
46 search_fields.add(new_option);
49 // ok, last member of array, so check the value of fuzzy_search
50 var fuzzy_search = server_fields[i];
51 var search_check_box = document.getElementById('rcmfd_ldap_public_search_type');
53 if (fuzzy_search == 'fuzzy') {
54 // we should enable the check box
55 if (search_check_box.disabled)
56 search_check_box.disabled = false;
58 // make sure the checkbox is unchecked
59 if (search_check_box.checked)
60 search_check_box.checked = false;
63 // we should disable the check box
64 if (!search_check_box.disabled)
65 search_check_box.disabled = true;
67 // check the checkbox (just a visual clue for the user)
68 if (!search_check_box.checked)
69 search_check_box.checked = true;