]> git.donarmstrong.com Git - roundcube.git/blob - skins/default/includes/ldapscripts.html
Imported Upstream version 0.2~alpha
[roundcube.git] / skins / default / includes / ldapscripts.html
1 <script type="text/javascript">
2 var ldap_server_select = document.getElementById('rcfmd_ldap_public_servers');
3
4 if (ldap_server_select) {
5   // attach event to ldap server drop down
6   ldap_server_select.onchange = function() {
7     updateLdapSearchFields(this);
8     return false;
9   }
10   
11   // update the fields on page load
12   updateLdapSearchFields(ldap_server_select);
13 }
14
15 /**
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 
18  */
19 function updateLdapSearchFields(element) {
20
21   // get the search fields select element
22   var search_fields = document.getElementById('rcfmd_ldap_public_search_field');
23
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);
27
28   // get the array containing this servers search fields
29   var server_fields = rcmail.env[element.value + '_search_fields'];
30
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++) {
33
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];
39
40       // standards compliant browsers
41       try {
42         search_fields.add(new_option, null);
43       }
44       // for the standards challenged one...
45       catch(e) {
46         search_fields.add(new_option);      
47       }
48     } else {
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');
52
53       if (fuzzy_search == 'fuzzy') {
54         // we should enable the check box
55         if (search_check_box.disabled)
56           search_check_box.disabled = false;
57
58         // make sure the checkbox is unchecked
59         if (search_check_box.checked)
60           search_check_box.checked = false;
61
62       } else {
63         // we should disable the check box
64         if (!search_check_box.disabled)
65           search_check_box.disabled = true;
66
67         // check the checkbox (just a visual clue for the user)
68         if (!search_check_box.checked)
69           search_check_box.checked = true;
70       }
71     }
72   }
73 }
74 </script>