source: trunk/expressoAdmin1_2/js/jscode/expressoadmin.js @ 5133

Revision 5133, 7.4 KB checked in by wmerlotto, 13 years ago (diff)

Ticket #2305 - Enviando alteracoes, desenvolvidas internamente na Prognus, do modulo ExpressoAdmin.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1        /************************************************************************************\
2        * Expresso Administração                                                                                                    *
3        * by Joao Alfredo Knopik Junior (joao.alfredo@gmail.com, jakjr@celepar.pr.gov.br)   *
4        * ----------------------------------------------------------------------------------*
5        *  This program is free software; you can redistribute it and/or modify it                      *
6        *  under the terms of the GNU General Public License as published by the                        *
7        *  Free Software Foundation; either version 2 of the License, or (at your                       *
8        *  option) any later version.                                                                                                           *
9        \************************************************************************************/
10
11function load_lang(){
12        cExecute ('$this/inc/load_lang', handler_load_lang);
13}
14
15var global_langs = new Array();
16var emailSugestion = 1;
17
18function handler_load_lang(data)
19{
20        global_langs = eval(data);
21}
22
23function get_associated_domain(context)
24{
25        var handler_associated_domain = function(data)
26        {
27                if (data != null)
28                {
29                        document.forms[0].associated_domain.value = data;
30                }
31                else
32                {
33                        document.forms[0].associated_domain.value = '';
34                }
35        };
36        cExecute ('$this.ldap_functions.get_associated_domain&context=' + context, handler_associated_domain);
37}
38
39function get_lang(key_raw)
40{
41        key = key_raw.replace(/ /g,"_");
42        key = key.replace(/-/g,"");
43        lang = eval("global_langs."+key.toLowerCase());
44       
45        if (typeof(lang)=='undefined')
46                return key_raw + '*';
47        else
48                return lang;
49}
50
51function emailSugestion_expressoadmin2(email) {         
52                if ( email.value.indexOf('@', 0) < 0 )  emailSugestion = 1;
53                if ( (email.value.indexOf('@', 0) == (email.value.length - 1)) && emailSugestion == 1 && email.value.length > 0 ) {
54                        var tmp;
55                        var context = "";
56
57                        organization_context = Element('ea_combo_org').value.toLowerCase();
58                        // Transformar os DN em User Friendly Naming format
59                        organization_name = organization_context.split(",");
60                        for (i in organization_name) {
61                                tmp = organization_name[i].split("=");
62                                context += tmp[1];
63                                if( i < (organization_name.length - 1) ) context +=  '.';
64                        }
65                        if (document.forms[0].associated_domain.value != '')
66                        {
67                                associatedDomain_name = document.forms[0].associated_domain.value;
68                                email.value = email.value + associatedDomain_name;
69                                emailSugestion = 0;
70                        } else{
71                                email.value = email.value + context;
72                                emailSugestion = 0;
73                        }
74                }               
75}
76
77function emailSuggestion_expressoadmin(use_suggestion_in_logon_script, concatenateDomain)
78{
79        if (concatenateDomain == 'true')
80        {
81                // base_dn do LDAP Expresso
82                var ldap_context = document.forms[0].ldap_context.value.toLowerCase();
83               
84                // OU selecionada
85                organization_context = document.forms[0].context.value.toLowerCase();
86               
87                select_orgs = document.getElementById('ea_combo_org_info');
88                for(var i=0; i<select_orgs.options.length; i++)
89                {
90                        if(select_orgs.options[i].selected == true)
91                        {
92                                var x;
93                                var context = '';
94                               
95                                // OU selecionada
96                                select_context = select_orgs.options[i].value.toLowerCase();
97                               
98                                // Transformar os DN em User Friendly Naming format
99                                organization_name = organization_context.split(",");
100                                for (x in organization_name)
101                                {
102                                        tmp = organization_name[x].split("=");
103                                        context += tmp[1] + '.';
104                                }
105                        }
106                }
107                domain_name = document.forms[0].defaultDomain.value;
108       
109                // Retira o base_dn do valor do dn e retorna o numero de caracteres.
110                x=context.indexOf(ldap_context,0);
111                // Obtenho a string, sem o base_dn
112                org_name_par = context.substring(0,(x-1));
113                // Obtenho o nome da organização: String entre pontos, anterior ao base_dn
114                org_name = org_name_par.split('.');
115                org_name = org_name[org_name.length-1];
116
117                if (org_name != '')
118                                document.forms[0].mail1.value = document.forms[0].uid.value + '@' + org_name + '.' + domain_name;
119                else
120                        document.forms[0].mail1.value = document.forms[0].uid.value;
121        }
122        else
123        {
124                document.forms[0].mail1.value = document.forms[0].uid.value;
125        }
126       
127        if (use_suggestion_in_logon_script == 'true')
128                document.forms[0].sambalogonscript.value = document.forms[0].uid.value+'.bat';
129        document.forms[0].sambahomedirectory.value = '/home/'+document.forms[0].uid.value+'/';
130}       
131
132function loadAppended( id, values, name )
133{
134    if( !values ) return;
135
136
137    if( typeof name === "undefined" || !name )
138        name = id + '[]';
139       
140    for( var i = 0; i < values.length; i++ )
141    {
142        if( !values[i] || values[i] === "" ) continue;
143
144        var clone = addTextbox( name, id );
145
146        clone.value = values[i];
147    }
148}
149
150function addTextbox( name, targetId, id )
151{
152    var input = document.createElement( "input" );
153    input.type = "text";
154    input.id = ( typeof id === "undefined" )? "" : id;
155    input.name = name;
156
157    var target = document.getElementById( targetId );
158
159    target.appendChild( input );
160
161    removable( input );
162
163    return( input );
164}
165
166function removable( target )
167{
168    with( target.parentNode )
169    {
170        var minus = document.createElement( "span" );
171        var br = document.createElement( "br" );
172
173        minus.innerHTML = " -";
174        minus.style.cursor = "pointer";
175        minus.onclick = function(){
176
177            removeChild( target );
178            removeChild( minus );
179            removeChild( br );
180        }
181
182        appendChild( minus );
183        appendChild( br );
184    }
185}
186
187function multiply( id, full )
188{
189    var target = document.getElementById( id );
190
191    var clone = target.cloneNode( false );
192
193    clone.id = "";
194
195    if( !full )
196        clone.value = "";
197
198    target.parentNode.appendChild( clone );
199
200    removable( clone );
201
202    return( clone );
203}
204
205function appendClone( id, full )
206{
207    return multiply( id, full );
208}
209
210function FormataValor(event, campo)
211{
212        separador1 = '(';
213        separador2 = ')';
214        separador3 = '-';
215               
216        vr = campo.value;
217        tam = vr.length;
218
219        if ((tam == 1) && (( event.keyCode != 8 ) || ( event.keyCode != 46 )))
220                campo.value = '';
221
222        if ((tam == 3) && (( event.keyCode != 8 ) || ( event.keyCode != 46 )))
223                campo.value = vr.substr( 0, tam - 1 );
224       
225        if (( tam <= 1 ) && ( event.keyCode != 8 ) && ( event.keyCode != 46 ))
226                campo.value = separador1 + vr;
227               
228        if (( tam == 3 ) && ( event.keyCode != 8 ) && ( event.keyCode != 46 ))
229                campo.value = vr + separador2;
230                       
231        if (( tam == 8 ) && (( event.keyCode != 8 ) && ( event.keyCode != 46 )))
232                campo.value = vr + separador3;
233
234        if ((( tam == 9 ) || ( tam == 8 )) && (( event.keyCode == 8 ) || ( event.keyCode == 46 )))
235                campo.value = vr.substr( 0, tam - 1 );
236}
237
238function FormataCPF(event, campo)
239{
240        if (event.keyCode == 8)
241                return;
242       
243        vr = campo.value;
244        tam = vr.length;
245       
246        var RegExp_onlyNumbers = new RegExp("[^0-9.-]+");
247        if ( RegExp_onlyNumbers.test(campo.value) )
248                campo.value = vr.substr( 0, (tam-1));
249       
250        if ( (campo.value.length == 3) || (campo.value.length == 7) )
251        {
252                campo.value += '.';
253        }
254       
255        if (campo.value.length == 11)
256                campo.value += '-';
257        return;
258       
259       
260        alert(campo.value);
261        return;
262       
263        separador1 = '.';
264        separador2 = '-';
265               
266        vr = campo.value;
267        tam = vr.length;
268
269        if ((tam == 1) && (( event.keyCode != 8 ) || ( event.keyCode != 46 )))
270                campo.value = '';
271
272        if ((tam == 3) && (( event.keyCode != 8 ) || ( event.keyCode != 46 )))
273                campo.value = vr.substr( 0, tam - 1 );
274       
275        if (( tam <= 1 ) && ( event.keyCode != 8 ) && ( event.keyCode != 46 ))
276                campo.value = separador1 + vr;
277               
278        if (( tam == 3 ) && ( event.keyCode != 8 ) && ( event.keyCode != 46 ))
279                campo.value = vr + separador2;
280                       
281        if (( tam == 8 ) && (( event.keyCode != 8 ) && ( event.keyCode != 46 )))
282                campo.value = vr + separador3;
283
284        if ((( tam == 9 ) || ( tam == 8 )) && (( event.keyCode == 8 ) || ( event.keyCode == 46 )))
285                campo.value = vr.substr( 0, tam - 1 );
286}
287load_lang();
Note: See TracBrowser for help on using the repository browser.