1 | function Im() |
---|
2 | { |
---|
3 | this.xtools = new XTools; |
---|
4 | this.conn = new Connector; |
---|
5 | this.vcard = false; |
---|
6 | this.status = null; |
---|
7 | this.statusFlag = null; |
---|
8 | this.contacts_off_line = null; |
---|
9 | this.timeOut_im = null; |
---|
10 | this.nickname_contacts = []; |
---|
11 | this.newMessageTimer = null; |
---|
12 | this.documentTitle = ""; |
---|
13 | this.notification_nm = false; |
---|
14 | this.notification_ch = false; |
---|
15 | } |
---|
16 | |
---|
17 | Im.prototype = { |
---|
18 | |
---|
19 | "addemotion" : function(pEmotion,pJid) |
---|
20 | { |
---|
21 | function get_Element(pJid) |
---|
22 | { |
---|
23 | var _document = document.getElementById('iframe_' + pJid); |
---|
24 | return _document.contentWindow.document.getElementsByTagName('body').item(0); |
---|
25 | } |
---|
26 | |
---|
27 | var content = get_Element(pJid); |
---|
28 | content.innerHTML += "" + this.insertEmoticons(pEmotion); |
---|
29 | }, |
---|
30 | |
---|
31 | "addrequest" : function(pEmail) |
---|
32 | { |
---|
33 | var email = pEmail; |
---|
34 | var name = pEmail.substr(0,pEmail.indexOf('@')); |
---|
35 | var group = 'default'; |
---|
36 | |
---|
37 | function handler_adduser(XmlData) |
---|
38 | { |
---|
39 | if(XmlData != "OK") |
---|
40 | alert("Contato não adicionado !"); |
---|
41 | } |
---|
42 | this.conn.go('$this.Ujabber.addContacts',{'request':handler_adduser},'email='+email+'&name='+name+'&group='+group); |
---|
43 | }, |
---|
44 | |
---|
45 | "adduser" : function() |
---|
46 | { |
---|
47 | if(!func.trim(func.byId('im_name').value) || !func.trim(func.byId('im_group').value)) |
---|
48 | alert('Informe todos os campos !'); |
---|
49 | else |
---|
50 | { |
---|
51 | var jid = func.byId('im_jid').value; |
---|
52 | var name = func.byId('im_name').value; |
---|
53 | var group = func.byId('im_group').value; |
---|
54 | var email = jid; |
---|
55 | |
---|
56 | if(func.byId('im_uid') != null) |
---|
57 | var uid = func.byId('im_uid').value; |
---|
58 | |
---|
59 | if(uid) |
---|
60 | email = uid + '@' + jid.substr((jid.indexOf('@')+1),jid.length); |
---|
61 | |
---|
62 | function handler_adduser(XmlData) |
---|
63 | { |
---|
64 | if(XmlData != "OK") |
---|
65 | alert("Contato não adicionado !"); |
---|
66 | else |
---|
67 | { |
---|
68 | function handler(Xmldata){}; |
---|
69 | con.go('$this.Ujabber.setPresence', {'request':handler},'type=unavailable'); |
---|
70 | alert("Contato Adicionado !"); |
---|
71 | var status = cookies_im.checkCookie('status'); |
---|
72 | im.status = status.substr(status.indexOf("=") + 1,status.length); |
---|
73 | setTimeout("im.presence(\'" + im.status + "\')",3000); |
---|
74 | } |
---|
75 | } |
---|
76 | this.conn.go('$this.Ujabber.addContacts',{'request':handler_adduser},'email='+email+'&name='+name+'&group='+group); |
---|
77 | } |
---|
78 | }, |
---|
79 | |
---|
80 | "button_color": function(pJid,pColor) |
---|
81 | { |
---|
82 | var _document = document.getElementById('iframe_' + pJid); |
---|
83 | var _font_color = ""; |
---|
84 | |
---|
85 | function get_Element(pJid) |
---|
86 | { |
---|
87 | return _document.contentWindow.document.getElementsByTagName('body').item(0); |
---|
88 | } |
---|
89 | var content = get_Element(pJid); |
---|
90 | |
---|
91 | if( _font_color = _document.contentWindow.document.getElementById('colors_'+pJid) ) |
---|
92 | content.innerHTML = "<span id='colors_"+pJid+"'style='color:"+pColor+"'>"+_font_color.innerHTML+"</span>"; |
---|
93 | else |
---|
94 | content.innerHTML = "<span id='colors_"+pJid+"'style='color:"+pColor+"'>"+content.innerHTML+"</span>"; |
---|
95 | }, |
---|
96 | |
---|
97 | "conf_font" : function(pJid,pAction) |
---|
98 | { |
---|
99 | function get_Element(pJid) |
---|
100 | { |
---|
101 | var _document = document.getElementById('iframe_' + pJid); |
---|
102 | return _document.contentWindow.document.getElementsByTagName('body').item(0); |
---|
103 | } |
---|
104 | |
---|
105 | switch(pAction) |
---|
106 | { |
---|
107 | case "button_bold" : |
---|
108 | var content = get_Element(pJid); |
---|
109 | content.innerHTML = "<span style='font-weight: bold;'>" + content.innerHTML + "</span>"; |
---|
110 | break; |
---|
111 | case "button_color" : |
---|
112 | templates.colors(pJid); |
---|
113 | break; |
---|
114 | case "button_emoticons" : |
---|
115 | templates.smiles(pJid); |
---|
116 | break; |
---|
117 | case "button_italic" : |
---|
118 | var content = get_Element(pJid); |
---|
119 | content.innerHTML = "<em>" + content.innerHTML + "</em>"; |
---|
120 | break; |
---|
121 | case "button_underline" : |
---|
122 | var content = get_Element(pJid); |
---|
123 | content.innerHTML = "<span style='text-decoration: underline;'>" + content.innerHTML + "</span>"; |
---|
124 | break; |
---|
125 | } |
---|
126 | }, |
---|
127 | |
---|
128 | "focus_select" : function(pObj,pEv) |
---|
129 | { |
---|
130 | pObj.focus(); |
---|
131 | pObj.select(); |
---|
132 | }, |
---|
133 | |
---|
134 | "get_contacts" : function() |
---|
135 | { |
---|
136 | var contact = func.byId('im_contact_list').firstChild; |
---|
137 | |
---|
138 | func.byId('im_remove_contact')[func.byId('im_remove_contact').length] = new Option('-- Selecione --', -1, true, true); |
---|
139 | |
---|
140 | while ( contact ) |
---|
141 | { |
---|
142 | if( contact.tagName == "DIV") |
---|
143 | { |
---|
144 | var options = new Option(contact.id.substr(0,contact.id.indexOf('@')), contact.id, false, true); |
---|
145 | func.byId('im_remove_contact')[func.byId('im_remove_contact').length] = options; |
---|
146 | } |
---|
147 | contact = contact.nextSibling; |
---|
148 | } |
---|
149 | |
---|
150 | func.byId('im_remove_contact')[0].selected = true; |
---|
151 | }, |
---|
152 | |
---|
153 | "get_lang" : function(_key, _arg1, _arg2, _arg3, _arg4) |
---|
154 | { |
---|
155 | var _value = ""; |
---|
156 | |
---|
157 | if ( !lang_im[_key.toLowerCase()] ) |
---|
158 | return _key + "*"; |
---|
159 | |
---|
160 | _value = lang_im[_key.toLowerCase()]; |
---|
161 | |
---|
162 | if ( _arg1 || _arg2 ||_arg3 || _arg4 ) |
---|
163 | { |
---|
164 | for (j = 1; j <= 4; j++ ) |
---|
165 | if( eval("_arg"+j) ) |
---|
166 | { |
---|
167 | var regExp = new RegExp("%" + j + ""); |
---|
168 | _value = _value.replace(regExp, eval("_arg"+j)); |
---|
169 | } |
---|
170 | } |
---|
171 | |
---|
172 | return _value; |
---|
173 | }, |
---|
174 | |
---|
175 | "get_preferences" : function() |
---|
176 | { |
---|
177 | var preferences = ""; |
---|
178 | |
---|
179 | function func_preferences(pString) |
---|
180 | { |
---|
181 | var result = pString.split(';'); |
---|
182 | |
---|
183 | for(var i in result) |
---|
184 | { |
---|
185 | var field = result[i].substr(0,result[i].indexOf(':')); |
---|
186 | var value = result[i].substr(result[i].indexOf(':') +1, result[i].length); |
---|
187 | if(value === 'true' || value === 'false') |
---|
188 | { |
---|
189 | if( func.byId(field) ) |
---|
190 | func.byId(field).checked = eval(value); |
---|
191 | |
---|
192 | if( field === "ch_offline" ) |
---|
193 | im.contacts_off_line = eval(value); |
---|
194 | |
---|
195 | if( field === "rd_nm" ) |
---|
196 | im.notification_nm = eval(value); |
---|
197 | |
---|
198 | if( field === "rd_ch" ) |
---|
199 | im.notification_ch = eval(value); |
---|
200 | } |
---|
201 | else |
---|
202 | { |
---|
203 | if(func.byId(field)) |
---|
204 | func.byId(field).value = value; |
---|
205 | im.timeOut_im = value; |
---|
206 | } |
---|
207 | } |
---|
208 | } |
---|
209 | |
---|
210 | if(preferences = cookies_im.checkCookie('preferences_im')) |
---|
211 | func_preferences(preferences); |
---|
212 | else |
---|
213 | { |
---|
214 | function handler_preferences(XmlData) |
---|
215 | { |
---|
216 | func_preferences(XmlData); |
---|
217 | cookies_im.setCookie('preferences_im', XmlData, null); |
---|
218 | } |
---|
219 | this.conn.go('$this.db_im.get_preferences',{'request':handler_preferences}); |
---|
220 | } |
---|
221 | }, |
---|
222 | |
---|
223 | "group_close" : function(pGroup) |
---|
224 | { |
---|
225 | var contact = func.byId('im_contact_list').firstChild; |
---|
226 | var img_group_close = new Image(); |
---|
227 | img_group_close.src = path_im + "templates/default/images/group_close.gif"; |
---|
228 | |
---|
229 | while ( contact ) |
---|
230 | { |
---|
231 | if(contact.getAttribute('idgroup') == pGroup) |
---|
232 | contact.style.display = "none"; |
---|
233 | contact = contact.nextSibling; |
---|
234 | } |
---|
235 | |
---|
236 | func.byId('group_' + pGroup).src = img_group_close.src; |
---|
237 | func.byId('group_' + pGroup).onclick = function(){im.group_open(pGroup)}; |
---|
238 | }, |
---|
239 | |
---|
240 | "group_open" : function(pGroup) |
---|
241 | { |
---|
242 | var contact = func.byId('im_contact_list').firstChild; |
---|
243 | var img_group_open = new Image(); |
---|
244 | img_group_open.src = path_im + "templates/default/images/group_open.gif"; |
---|
245 | |
---|
246 | while ( contact ) |
---|
247 | { |
---|
248 | if(contact.getAttribute('idgroup') == pGroup) |
---|
249 | contact.style.display = "block"; |
---|
250 | contact = contact.nextSibling; |
---|
251 | } |
---|
252 | |
---|
253 | func.byId('group_' + pGroup).src = img_group_open.src; |
---|
254 | func.byId('group_' + pGroup).onclick = function(){im.group_close(pGroup)}; |
---|
255 | }, |
---|
256 | |
---|
257 | "insertEmoticons" : function(pEmotion) |
---|
258 | { |
---|
259 | var emotion_regexp; |
---|
260 | |
---|
261 | for ( i in cod_emotions ) |
---|
262 | { |
---|
263 | try |
---|
264 | { |
---|
265 | emotion_regexp = new RegExp(cod_emotions[i][1], 'gi'); |
---|
266 | if ( emotion_regexp.test(pEmotion) ) |
---|
267 | { |
---|
268 | var image = eval('smile_' + cod_emotions[i][0] + '.src.substr(smile_' +cod_emotions[i][0] + '.src.indexOf(path_im))'); |
---|
269 | emotion_regexp = new RegExp(cod_emotions[i][1], 'gi'); |
---|
270 | pEmotion = pEmotion.replace(emotion_regexp, '<img emotion="' + i + '" src="' + image + '">'); |
---|
271 | } |
---|
272 | }catch(e){} |
---|
273 | } |
---|
274 | return pEmotion; |
---|
275 | }, |
---|
276 | |
---|
277 | "ldap" : function() |
---|
278 | { |
---|
279 | var _this = this; |
---|
280 | |
---|
281 | function handler_ldap(XmlData) |
---|
282 | { |
---|
283 | func.byId('im_ldap_ou').innerHTML = _this.xtools.parse(XmlData,'list_ldap_org.xsl'); |
---|
284 | } |
---|
285 | this.conn.go('$this.ldap_im.list_organizations_ldap', {'request':handler_ldap}); |
---|
286 | }, |
---|
287 | |
---|
288 | "ldap_adduser" : function(pElement) |
---|
289 | { |
---|
290 | if(pElement.options.length > 0) |
---|
291 | for(var i=0; i < pElement.options.length; i++) |
---|
292 | if(pElement.options[i].selected == true) |
---|
293 | { |
---|
294 | document.getElementById('im_jid').value = pElement.options[i].value.substr(0,pElement.options[i].value.indexOf(';')); |
---|
295 | document.getElementById('im_name').value = pElement.options[i].value.substr(0,pElement.options[i].value.indexOf('@')); |
---|
296 | document.getElementById('im_group').focus(); |
---|
297 | document.getElementById('im_uid').value = pElement.options[i].value.substr((pElement.options[i].value.indexOf(';')+1), pElement.options[i].value.length); |
---|
298 | } |
---|
299 | }, |
---|
300 | |
---|
301 | "ldap_search_ou" : function(pElement) |
---|
302 | { |
---|
303 | var ldap_ou = ""; |
---|
304 | |
---|
305 | for(var i=0; i < pElement.options.length; i++) |
---|
306 | if( pElement.options[i].selected == true ) |
---|
307 | { |
---|
308 | ldap_ou = pElement.options[i].value; |
---|
309 | document.getElementById('im_jid').value = ""; |
---|
310 | document.getElementById('im_name').value = ""; |
---|
311 | document.getElementById('im_ldap_user').innerHTML = ""; |
---|
312 | } |
---|
313 | |
---|
314 | if(ldap_ou) |
---|
315 | this.ldap_search_contacts(ldap_ou); |
---|
316 | }, |
---|
317 | |
---|
318 | "ldap_search_contacts" : function(pOu) |
---|
319 | { |
---|
320 | var _this = this; |
---|
321 | document.getElementById('_span_load_im').style.display = "block"; |
---|
322 | |
---|
323 | function handler_ldap(XmlData) |
---|
324 | { |
---|
325 | document.getElementById('im_ldap_user').innerHTML = _this.xtools.parse(XmlData,'list_ldap_contacts.xsl'); |
---|
326 | document.getElementById('_span_load_im').style.display = "none"; |
---|
327 | } |
---|
328 | |
---|
329 | this.conn.go('$this.contacts_im.list_contacts',{'request':handler_ldap}, 'ou='+pOu); |
---|
330 | }, |
---|
331 | |
---|
332 | "ldap_photo" : function(pAvatar) |
---|
333 | { |
---|
334 | var uid = pAvatar; |
---|
335 | |
---|
336 | if(pAvatar != 'im_avatar') |
---|
337 | var uid = pAvatar.substr(0,pAvatar.indexOf('@')); |
---|
338 | |
---|
339 | if( func.byId(pAvatar).src != im_photo_1.src ) |
---|
340 | { |
---|
341 | function handler_ldap_photo(XmlData) |
---|
342 | { |
---|
343 | var data = eval(XmlData); |
---|
344 | if( data ) |
---|
345 | { |
---|
346 | if( document.getElementById(pAvatar) != null ) |
---|
347 | { |
---|
348 | var photo_img = document.getElementById(pAvatar); |
---|
349 | photo_img.src = ( path_im + "inc/class.ldap_im.inc.php?user="+uid ) ? path_im + "inc/class.ldap_im.inc.php?user="+uid : im_photo.src ; |
---|
350 | } |
---|
351 | } |
---|
352 | else |
---|
353 | func.byId(pAvatar).src = im_photo_1.src; |
---|
354 | } |
---|
355 | this.conn.go('$this.ldap_im.photo_ldap',{'request':handler_ldap_photo},'uid='+uid); |
---|
356 | } |
---|
357 | }, |
---|
358 | |
---|
359 | "newMessageNotification" : function() |
---|
360 | { |
---|
361 | if ( !focusFlag ) |
---|
362 | { |
---|
363 | if( this.notification_nm ) |
---|
364 | { |
---|
365 | if ( document.title == "......................" ) |
---|
366 | document.title = "New Message!"; |
---|
367 | else |
---|
368 | document.title = "......................"; |
---|
369 | |
---|
370 | if ( this.newMessageTimer ) |
---|
371 | clearTimeout( this.newMessageTimer ); |
---|
372 | this.newMessageTimer = setTimeout("im.newMessageNotification()", 1000); |
---|
373 | } |
---|
374 | |
---|
375 | if( this.notification_ch ) |
---|
376 | { |
---|
377 | if(self.moveBy) |
---|
378 | { |
---|
379 | for( var i = 20 ; i > 0 ; i--) |
---|
380 | { |
---|
381 | self.moveBy(i,0); |
---|
382 | self.moveBy(-i,0); |
---|
383 | } |
---|
384 | } |
---|
385 | } |
---|
386 | } |
---|
387 | else |
---|
388 | { |
---|
389 | if ( this.newMessageTimer ) |
---|
390 | clearTimeout( this.newMessageTimer ); |
---|
391 | } |
---|
392 | }, |
---|
393 | |
---|
394 | "off_line" : function() |
---|
395 | { |
---|
396 | if( func.byId('im_contact_list') != null) |
---|
397 | { |
---|
398 | var group = func.byId('im_contact_list').firstChild; |
---|
399 | |
---|
400 | while(group) |
---|
401 | { |
---|
402 | if(group.hasChildNodes()) |
---|
403 | { |
---|
404 | if(group.id) |
---|
405 | { |
---|
406 | if(!this.contacts_off_line) |
---|
407 | { |
---|
408 | if( func.byId('img_' + group.id).src === im_unavailable.src ) |
---|
409 | func.confEl(group,"style","margin-left:15px;cursor:pointer;display:none;"); |
---|
410 | } |
---|
411 | else |
---|
412 | { |
---|
413 | func.confEl(group,"style","margin-left:15px;cursor:pointer;display:block;"); |
---|
414 | } |
---|
415 | } |
---|
416 | } |
---|
417 | group = group.nextSibling; |
---|
418 | } |
---|
419 | } |
---|
420 | }, |
---|
421 | |
---|
422 | "presence" : function(pType) |
---|
423 | { |
---|
424 | var imgStatus = null; |
---|
425 | |
---|
426 | switch(pType) |
---|
427 | { |
---|
428 | case 'away' : |
---|
429 | case 'dnd' : |
---|
430 | case 'xa' : |
---|
431 | this.status = 'show='+pType; |
---|
432 | this.statusFlag = pType; |
---|
433 | imgStatus = pType; |
---|
434 | break; |
---|
435 | case 'available' : |
---|
436 | case 'unavailable' : |
---|
437 | this.status = 'type='+pType; |
---|
438 | this.statusFlag = pType; |
---|
439 | imgStatus = pType; |
---|
440 | break; |
---|
441 | case 'custom' : |
---|
442 | var custom = prompt('Personalize seu Status : '); |
---|
443 | if(custom) |
---|
444 | this.status = 'status='+custom; |
---|
445 | else |
---|
446 | return; |
---|
447 | } |
---|
448 | |
---|
449 | cookies_im.setCookie('status', this.status, null); |
---|
450 | function handler_presence(XmlData) |
---|
451 | { |
---|
452 | if(imgStatus != null) |
---|
453 | func.byId('im_status_src').src = eval('im_' + imgStatus + '.src'); |
---|
454 | } |
---|
455 | this.conn.go('$this.Ujabber.setPresence', {'request' : handler_presence}, this.status); |
---|
456 | }, |
---|
457 | |
---|
458 | "remove" : function(pJid) |
---|
459 | { |
---|
460 | if(confirm('Deseja excluir o contato ' + pJid + ' ?')) |
---|
461 | { |
---|
462 | function handler_remove(XmlData) |
---|
463 | { |
---|
464 | if(XmlData == "OK") |
---|
465 | { |
---|
466 | func.byId(pJid).parentNode.removeChild(func.byId(pJid)); |
---|
467 | function handler(Xmldata){}; |
---|
468 | con.go('$this.Ujabber.setPresence', {'request':handler},'type=unavailable'); |
---|
469 | var status = cookies_im.checkCookie('status'); |
---|
470 | im.status = status.substr(status.indexOf("=") + 1,status.length); |
---|
471 | setTimeout("im.presence(\'" + im.status + "\')",3000); |
---|
472 | } |
---|
473 | } |
---|
474 | this.conn.go('$this.Ujabber.removeContact',{'request':handler_remove},'jid='+pJid); |
---|
475 | } |
---|
476 | }, |
---|
477 | |
---|
478 | "remove_contact" : function(pElement) |
---|
479 | { |
---|
480 | var Jid = ""; |
---|
481 | |
---|
482 | if( func.byId(pElement).options.length > 0 ) |
---|
483 | for(var i=0; i < func.byId(pElement).options.length; i++) |
---|
484 | if( func.byId(pElement).options[i].selected == true ) |
---|
485 | Jid = func.byId(pElement).options[i].value; |
---|
486 | |
---|
487 | if(confirm('Deseja excluir o contato ' + Jid + ' ?')) |
---|
488 | { |
---|
489 | if( Jid && Jid != -1 ) |
---|
490 | { |
---|
491 | function handler_remove(XmlData) |
---|
492 | { |
---|
493 | if(XmlData == "OK") |
---|
494 | { |
---|
495 | func.byId(Jid).parentNode.removeChild(func.byId(Jid)); |
---|
496 | for(var i=0 ; i < func.byId(pElement).options.length; i++) |
---|
497 | { |
---|
498 | func.byId(pElement).options[i] = null; |
---|
499 | i--; |
---|
500 | } |
---|
501 | } |
---|
502 | im.get_contacts(); |
---|
503 | } |
---|
504 | this.conn.go('$this.Ujabber.removeContact',{'request':handler_remove},'jid='+Jid); |
---|
505 | } |
---|
506 | } |
---|
507 | }, |
---|
508 | |
---|
509 | "request_vcard" : function(pJid, pVcard) |
---|
510 | { |
---|
511 | this.vcard = pVcard; |
---|
512 | function handler_getVcard(XmlData){} |
---|
513 | this.conn.go('$this.Ujabber.getVcard',{'request':handler_getVcard},'jid='+pJid); |
---|
514 | }, |
---|
515 | |
---|
516 | "save_vcard" : function() |
---|
517 | { |
---|
518 | |
---|
519 | var xmlVcard = "<FN>" + func.byId('im_fn').value + "</FN>"; |
---|
520 | xmlVcard += "<NICKNAME>" + func.byId('im_nickname').value + "</NICKNAME>"; |
---|
521 | xmlVcard += "<ORG>"; |
---|
522 | xmlVcard += "<ORGNAME>" + func.byId('im_orgname').value + "</ORGNAME>"; |
---|
523 | xmlVcard += "<ORGUNIT>" + func.byId('im_orgunit').value + "</ORGUNIT>"; |
---|
524 | xmlVcard += "</ORG>"; |
---|
525 | xmlVcard += "<ROLE>" + func.byId('im_role').value + "</ROLE>"; |
---|
526 | xmlVcard += "<BDAY>" + func.byId('im_bday').value + "</BDAY>"; |
---|
527 | |
---|
528 | func.byId('im_layer_nickname').innerHTML = func.byId('im_nickname').value; |
---|
529 | |
---|
530 | function handler_savevcard(XmlData) |
---|
531 | { |
---|
532 | if( XmlData != "OK" ) |
---|
533 | alert('Vcard não cadastrado/atualizado !'); |
---|
534 | else |
---|
535 | alert('Vcard cadastrado/atualizado !'); |
---|
536 | } |
---|
537 | this.conn.go('$this.Ujabber.newVcard',{'request':handler_savevcard},"vcard="+xmlVcard); |
---|
538 | |
---|
539 | }, |
---|
540 | |
---|
541 | "set_preferences" : function() |
---|
542 | { |
---|
543 | var preferences = ""; |
---|
544 | var numbers = /^\d+$/; |
---|
545 | |
---|
546 | this.timeOut_im = 1; |
---|
547 | preferences = (func.byId('ch_offline').checked ) ? 'ch_offline:true;' : 'ch_offline:false;'; |
---|
548 | this.contacts_off_line = func.byId('ch_offline').checked; |
---|
549 | if(numbers.test(func.byId('time_xa_im').value) && func.byId('time_xa_im').value != "0") |
---|
550 | { |
---|
551 | preferences += "time_xa_im:" + func.byId('time_xa_im').value + ";"; |
---|
552 | this.timeOut_im = func.byId('time_xa_im').value; |
---|
553 | } |
---|
554 | else |
---|
555 | preferences += "time_xa_im:1;"; |
---|
556 | |
---|
557 | preferences += ( func.byId('rd_nm').checked ) ? 'rd_nm:true;' : 'rd_nm:false;'; |
---|
558 | this.notification_nm = ( func.byId('rd_nm').checked ) ? true : false; |
---|
559 | preferences += ( func.byId('rd_ch').checked ) ? 'rd_ch:true' : 'rd_ch:false'; |
---|
560 | this.notification_ch = ( func.byId('rd_ch').checked ) ? true : false; |
---|
561 | |
---|
562 | function handler_preferences(XmlData) |
---|
563 | { |
---|
564 | if(XmlData === "true") |
---|
565 | { |
---|
566 | cookies_im.setCookie('preferences_im', preferences, null); |
---|
567 | im.off_line(); |
---|
568 | alert('Preferências Salvas !'); |
---|
569 | } |
---|
570 | } |
---|
571 | this.conn.go('$this.db_im.set_preferences',{'request':handler_preferences},'preferences='+preferences); |
---|
572 | }, |
---|
573 | |
---|
574 | "set_timeOut" : function() |
---|
575 | { |
---|
576 | if( this.statusFlag === 'available') |
---|
577 | setTimeout("im.presence(\'xa\')",parseInt(im.timeOut_im)); |
---|
578 | }, |
---|
579 | |
---|
580 | "subscription" : function(pJid, pType) |
---|
581 | { |
---|
582 | function handler_request(XmlData) |
---|
583 | { |
---|
584 | if(XmlData != 1) |
---|
585 | alert(XmlData); |
---|
586 | } |
---|
587 | this.conn.go('$this.Ujabber.subscription',{'request':handler_request},"jid="+pJid+"&type="+pType); |
---|
588 | }, |
---|
589 | |
---|
590 | "update_nickname" : function(pJid) |
---|
591 | { |
---|
592 | var jid = pJid; |
---|
593 | var name = func.byId(pJid).getAttribute('idname'); |
---|
594 | var group = func.byId(pJid).getAttribute('idgroup'); |
---|
595 | cookies_im.setCookie('contacts', pJid + "=" + func.byId("img_"+ pJid).src, 1); |
---|
596 | |
---|
597 | if( value = prompt("Digite um novo apelido para : " + jid, "" )) |
---|
598 | { |
---|
599 | if(func.trim(value) != "" && value != null) |
---|
600 | { |
---|
601 | name = value; |
---|
602 | function handler_update_contact(XmlData) |
---|
603 | { |
---|
604 | if(XmlData != "OK") |
---|
605 | alert('Contato não atualizado !'); |
---|
606 | else |
---|
607 | { |
---|
608 | function handler(Xmldata){}; |
---|
609 | con.go('$this.Ujabber.setPresence', {'request':handler},'type=unavailable'); |
---|
610 | |
---|
611 | var status = cookies_im.checkCookie('status'); |
---|
612 | im.status = status.substr(status.indexOf("=") + 1,status.length); |
---|
613 | setTimeout("im.presence(\'" + im.status + "\')",3000); |
---|
614 | } |
---|
615 | } |
---|
616 | this.conn.go('$this.Ujabber.updateContact',{'request':handler_update_contact},"jid="+jid+"&name="+name+"&group="+group); |
---|
617 | } |
---|
618 | } |
---|
619 | }, |
---|
620 | |
---|
621 | "update_group" : function(pJid) |
---|
622 | { |
---|
623 | var jid = pJid; |
---|
624 | var name = func.byId(pJid).getAttribute('idname'); |
---|
625 | var group = func.byId(pJid).getAttribute('idgroup'); |
---|
626 | cookies_im.setCookie('contacts', pJid + "=" + func.byId("img_"+ pJid).src, 1); |
---|
627 | |
---|
628 | if( value = prompt("Digite um novo grupo para : " + jid, "" )) |
---|
629 | { |
---|
630 | if(func.trim(value) != "" && value != null) |
---|
631 | { |
---|
632 | group = value; |
---|
633 | function handler_update_contact(XmlData) |
---|
634 | { |
---|
635 | if(XmlData != "OK") |
---|
636 | alert('Contato não atualizado !'); |
---|
637 | else |
---|
638 | { |
---|
639 | function handler(Xmldata){}; |
---|
640 | con.go('$this.Ujabber.setPresence', {'request':handler},'type=unavailable'); |
---|
641 | var status = cookies_im.checkCookie('status'); |
---|
642 | im.status = status.substr(status.indexOf("=") + 1,status.length); |
---|
643 | setTimeout("im.presence(\'" + im.status + "\')",3000); |
---|
644 | } |
---|
645 | } |
---|
646 | this.conn.go('$this.Ujabber.updateContact',{'request':handler_update_contact},"jid="+jid+"&name="+name+"&group="+group); |
---|
647 | } |
---|
648 | } |
---|
649 | } |
---|
650 | } |
---|
651 | var im = new Im(); |
---|