1 | (function() |
---|
2 | { |
---|
3 | var _conn = ''; |
---|
4 | var _xtools = ''; |
---|
5 | |
---|
6 | function addGroup() |
---|
7 | { |
---|
8 | var select_ldap = document.getElementById('groups_ldap'); |
---|
9 | for(var i = 0; i < select_ldap.options.length ; i++) |
---|
10 | if( select_ldap.options[i].selected ) |
---|
11 | { |
---|
12 | var select_voip = document.getElementById('groups_voip'); |
---|
13 | var flag = false; |
---|
14 | for(var j = 0; j < select_voip.options.length ; j++ ) |
---|
15 | { |
---|
16 | if( select_voip.options[j].value === select_ldap.options[i].value ) |
---|
17 | flag = true; |
---|
18 | } |
---|
19 | if ( !flag ) { |
---|
20 | var option = select_ldap.options[i].value.split(";"); |
---|
21 | select_voip.options[select_voip.length] = new Option(option[0], select_ldap.options[i].value, false, true); |
---|
22 | } |
---|
23 | } |
---|
24 | } |
---|
25 | |
---|
26 | function createObject() |
---|
27 | { |
---|
28 | if ( typeof(_conn) != "object") |
---|
29 | _conn = new ADMConnector(path_adm + 'admin' ); |
---|
30 | |
---|
31 | if ( typeof(_xtools) != "object" ) |
---|
32 | _xtools = new ADMXTools(path_adm + 'admin'); |
---|
33 | } |
---|
34 | |
---|
35 | function CompleteSelect(data) |
---|
36 | { |
---|
37 | var select_ldap = document.getElementById('groups_ldap'); |
---|
38 | data = _xtools.convert(data); |
---|
39 | |
---|
40 | while( select_ldap.hasChildNodes()) |
---|
41 | select_ldap.removeChild(select_ldap.firstChild); |
---|
42 | |
---|
43 | try |
---|
44 | { |
---|
45 | if ( data && data.documentElement && data.documentElement.hasChildNodes() ) |
---|
46 | { |
---|
47 | data = data.documentElement.firstChild; |
---|
48 | |
---|
49 | while(data) |
---|
50 | { |
---|
51 | var option = data.firstChild.nodeValue.split(";"); |
---|
52 | select_ldap.options[select_ldap.options.length] = new Option(option[0],data.firstChild.nodeValue, false, false); |
---|
53 | data = data.nextSibling; |
---|
54 | } |
---|
55 | } |
---|
56 | }catch(e){} |
---|
57 | |
---|
58 | styleVisible('hidden'); |
---|
59 | } |
---|
60 | |
---|
61 | function SearchOu() |
---|
62 | { |
---|
63 | createObject(); |
---|
64 | var organization = ""; |
---|
65 | |
---|
66 | if( arguments.length > 0 ) |
---|
67 | { |
---|
68 | var element = arguments[0]; |
---|
69 | styleVisible('visible'); |
---|
70 | } |
---|
71 | |
---|
72 | if( element.options.length > 0 ) |
---|
73 | for(var i = 0; i < element.options.length ; i++ ) |
---|
74 | if( element.options[i].selected ) |
---|
75 | organization = element.options[i].value; |
---|
76 | |
---|
77 | organization = 'ou=' + organization; |
---|
78 | |
---|
79 | _conn.go('$this.bovoip.getGroupsLdap', CompleteSelect, organization); |
---|
80 | } |
---|
81 | |
---|
82 | function Selected() |
---|
83 | { |
---|
84 | var select_voip = document.getElementById('groups_voip'); |
---|
85 | for(var i = 0 ; i < select_voip.options.length; i++ ) |
---|
86 | select_voip.options[i].selected = true; |
---|
87 | } |
---|
88 | |
---|
89 | function styleVisible(pVisible) |
---|
90 | { |
---|
91 | document.getElementById('admin_span_loading').style.visibility = pVisible; |
---|
92 | } |
---|
93 | |
---|
94 | function removeGroup() |
---|
95 | { |
---|
96 | var select_voip = document.getElementById('groups_voip'); |
---|
97 | |
---|
98 | for(var i = 0 ; i < select_voip.options.length; i++ ) |
---|
99 | if( select_voip.options[i].selected ) |
---|
100 | { |
---|
101 | select_voip.options[i].parentNode.removeChild(select_voip.options[i]); |
---|
102 | i--; |
---|
103 | } |
---|
104 | } |
---|
105 | |
---|
106 | function Voip() |
---|
107 | { |
---|
108 | |
---|
109 | } |
---|
110 | |
---|
111 | Voip.prototype.search = SearchOu; |
---|
112 | Voip.prototype.add = addGroup; |
---|
113 | Voip.prototype.remove = removeGroup; |
---|
114 | Voip.prototype.select_ = Selected; |
---|
115 | window.voip = new Voip; |
---|
116 | |
---|
117 | })(); |
---|