1 | function Im() |
---|
2 | { |
---|
3 | this.xtools = new XTools; |
---|
4 | this.conn = new Connector; |
---|
5 | } |
---|
6 | |
---|
7 | Im.prototype = { |
---|
8 | |
---|
9 | "get_contacts" : function() |
---|
10 | { |
---|
11 | var contact = func.byId('im_contact_list').firstChild; |
---|
12 | |
---|
13 | func.byId('im_remove_contact')[func.byId('im_remove_contact').length] = new Option('-- Selecione --', -1, true, true); |
---|
14 | |
---|
15 | while ( contact ) |
---|
16 | { |
---|
17 | if( contact.tagName == "DIV") |
---|
18 | { |
---|
19 | var options = new Option(contact.id.substr(0,contact.id.indexOf('@')), contact.id, false, true); |
---|
20 | func.byId('im_remove_contact')[func.byId('im_remove_contact').length] = options; |
---|
21 | } |
---|
22 | contact = contact.nextSibling; |
---|
23 | } |
---|
24 | |
---|
25 | func.byId('im_remove_contact')[0].selected = true; |
---|
26 | }, |
---|
27 | |
---|
28 | "ldap" : function() |
---|
29 | { |
---|
30 | var _this = this; |
---|
31 | |
---|
32 | function handler_ldap(XmlData) |
---|
33 | { |
---|
34 | document.getElementById('im_ldap_ou').innerHTML = _this.xtools.parse(XmlData,'list_ldap_org.xsl'); |
---|
35 | } |
---|
36 | this.conn.go('$this.ldap_im.list_organizations_ldap', {'request':handler_ldap}); |
---|
37 | }, |
---|
38 | |
---|
39 | "ldap_adduser" : function(pElement) |
---|
40 | { |
---|
41 | if(pElement.options.length > 0) |
---|
42 | for(var i=0; i < pElement.options.length; i++) |
---|
43 | if(pElement.options[i].selected == true) |
---|
44 | { |
---|
45 | document.getElementById('text0').value = pElement.options[i].value.substr(0,pElement.options[i].value.indexOf(';')); |
---|
46 | document.getElementById('text1').value = pElement.options[i].value.substr(0,pElement.options[i].value.indexOf('@')); |
---|
47 | document.getElementById('text2').focus(); |
---|
48 | document.getElementById('text3').value = pElement.options[i].value.substr((pElement.options[i].value.indexOf(';')+1), pElement.options[i].value.length); |
---|
49 | } |
---|
50 | }, |
---|
51 | |
---|
52 | "ldap_search_ou" : function(pElement) |
---|
53 | { |
---|
54 | var ldap_ou = ""; |
---|
55 | |
---|
56 | for(var i=0; i < pElement.options.length; i++) |
---|
57 | if( pElement.options[i].selected == true ) |
---|
58 | { |
---|
59 | ldap_ou = pElement.options[i].value; |
---|
60 | document.getElementById('text0').value = ""; |
---|
61 | document.getElementById('text1').value = ""; |
---|
62 | document.getElementById('im_ldap_user').innerHTML = ""; |
---|
63 | } |
---|
64 | |
---|
65 | if(ldap_ou) |
---|
66 | this.ldap_search_contacts(ldap_ou); |
---|
67 | }, |
---|
68 | |
---|
69 | "ldap_search_contacts" : function(pOu) |
---|
70 | { |
---|
71 | var _this = this; |
---|
72 | document.getElementById('_span_load_im').style.display = "block"; |
---|
73 | |
---|
74 | function handler_ldap(XmlData) |
---|
75 | { |
---|
76 | document.getElementById('im_ldap_user').innerHTML = _this.xtools.parse(XmlData,'list_ldap_contacts.xsl'); |
---|
77 | document.getElementById('_span_load_im').style.display = "none"; |
---|
78 | } |
---|
79 | |
---|
80 | this.conn.go('$this.contacts_im.list_contacts',{'request':handler_ldap}, 'ou='+pOu); |
---|
81 | }, |
---|
82 | |
---|
83 | "remove_contact" : function(pElement) |
---|
84 | { |
---|
85 | var Jid = ""; |
---|
86 | |
---|
87 | if( func.byId(pElement).options.length > 0 ) |
---|
88 | for(var i=0; i < func.byId(pElement).options.length; i++) |
---|
89 | if( func.byId(pElement).options[i].selected == true ) |
---|
90 | Jid = func.byId(pElement).options[i].value; |
---|
91 | |
---|
92 | if( Jid && Jid != -1 ) |
---|
93 | { |
---|
94 | func.byId(Jid).parentNode.removeChild(func.byId(Jid)); |
---|
95 | for(var i=0 ; i < func.byId(pElement).options.length; i++) |
---|
96 | { |
---|
97 | func.byId(pElement).options[i] = null; |
---|
98 | i--; |
---|
99 | } |
---|
100 | this.get_contacts(); |
---|
101 | } |
---|
102 | } |
---|
103 | } |
---|
104 | var im = new Im(); |
---|