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 LTrim(value) |
---|
62 | { |
---|
63 | var w_space = String.fromCharCode(32); |
---|
64 | var strTemp = ""; |
---|
65 | var iTemp = 0; |
---|
66 | |
---|
67 | if(v_length < 1) |
---|
68 | return ""; |
---|
69 | |
---|
70 | var v_length = value ? value.length : 0; |
---|
71 | |
---|
72 | while(iTemp < v_length) |
---|
73 | { |
---|
74 | if(value && value.charAt(iTemp) != w_space) |
---|
75 | { |
---|
76 | strTemp = value.substring(iTemp,v_length); |
---|
77 | break; |
---|
78 | } |
---|
79 | iTemp++; |
---|
80 | } |
---|
81 | return strTemp; |
---|
82 | } |
---|
83 | |
---|
84 | |
---|
85 | function SearchOu() |
---|
86 | { |
---|
87 | createObject(); |
---|
88 | var organization = ""; |
---|
89 | |
---|
90 | if( arguments.length > 0 ) |
---|
91 | { |
---|
92 | var element = arguments[0]; |
---|
93 | styleVisible('visible'); |
---|
94 | } |
---|
95 | |
---|
96 | if( element.options.length > 0 ) |
---|
97 | for(var i = 0; i < element.options.length ; i++ ) |
---|
98 | if( element.options[i].selected ) |
---|
99 | organization = 'ou=' + element.options[i].value; |
---|
100 | |
---|
101 | _conn.go('$this.bovoip.getGroupsLdap', CompleteSelect, organization); |
---|
102 | } |
---|
103 | |
---|
104 | function Selected() |
---|
105 | { |
---|
106 | var select_voip = document.getElementById('groups_voip'); |
---|
107 | for( var i = 0 ; i < select_voip.options.length; i++ ) |
---|
108 | select_voip.options[i].selected = true; |
---|
109 | } |
---|
110 | |
---|
111 | function styleVisible(pVisible) |
---|
112 | { |
---|
113 | document.getElementById('admin_span_loading').style.visibility = pVisible; |
---|
114 | } |
---|
115 | |
---|
116 | function removeGroup() |
---|
117 | { |
---|
118 | var select_voip = document.getElementById('groups_voip'); |
---|
119 | |
---|
120 | for(var i = 0 ; i < select_voip.options.length; i++ ) |
---|
121 | if( select_voip.options[i].selected ) |
---|
122 | { |
---|
123 | select_voip.options[i].parentNode.removeChild(select_voip.options[i]); |
---|
124 | i--; |
---|
125 | } |
---|
126 | } |
---|
127 | |
---|
128 | function validateEmail() |
---|
129 | { |
---|
130 | if( arguments.length > 0 ) |
---|
131 | { |
---|
132 | var element = arguments[0]; |
---|
133 | var validate = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; |
---|
134 | |
---|
135 | if(LTrim(element.value) != "" && element.value != "") |
---|
136 | { |
---|
137 | if(!validate.test(element.value)) |
---|
138 | { |
---|
139 | alert('Email field is not valid' + '.'); |
---|
140 | element.focus(); |
---|
141 | return false; |
---|
142 | } |
---|
143 | } |
---|
144 | } |
---|
145 | } |
---|
146 | |
---|
147 | function Voip() |
---|
148 | { |
---|
149 | |
---|
150 | } |
---|
151 | |
---|
152 | Voip.prototype.search = SearchOu; |
---|
153 | Voip.prototype.add = addGroup; |
---|
154 | Voip.prototype.remove = removeGroup; |
---|
155 | Voip.prototype.select_ = Selected; |
---|
156 | Voip.prototype.validateEmail = validateEmail; |
---|
157 | window.voip = new Voip; |
---|
158 | |
---|
159 | })(); |
---|