source: companies/serpro/admin/js/voip/functions.js @ 903

Revision 903, 2.6 KB checked in by niltonneto, 15 years ago (diff)

Importacao inicial do Expresso do Serpro

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