| 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 | var group = func.byId('im_contact_list').firstChild; |
---|
| 397 | |
---|
| 398 | while(group) |
---|
| 399 | { |
---|
| 400 | if(group.hasChildNodes()) |
---|
| 401 | { |
---|
| 402 | if(group.id) |
---|
| 403 | { |
---|
| 404 | if(!this.contacts_off_line) |
---|
| 405 | { |
---|
| 406 | if( func.byId('img_' + group.id).src === im_unavailable.src ) |
---|
| 407 | func.confEl(group,"style","margin-left:15px;cursor:pointer;display:none;"); |
---|
| 408 | } |
---|
| 409 | else |
---|
| 410 | { |
---|
| 411 | func.confEl(group,"style","margin-left:15px;cursor:pointer;display:block;"); |
---|
| 412 | } |
---|
| 413 | } |
---|
| 414 | } |
---|
| 415 | group = group.nextSibling; |
---|
| 416 | } |
---|
| 417 | }, |
---|
| 418 | |
---|
| 419 | "presence" : function(pType) |
---|
| 420 | { |
---|
| 421 | var imgStatus = null; |
---|
| 422 | |
---|
| 423 | switch(pType) |
---|
| 424 | { |
---|
| 425 | case 'away' : |
---|
| 426 | case 'dnd' : |
---|
| 427 | case 'xa' : |
---|
| 428 | this.status = 'show='+pType; |
---|
| 429 | this.statusFlag = pType; |
---|
| 430 | imgStatus = pType; |
---|
| 431 | break; |
---|
| 432 | case 'available' : |
---|
| 433 | case 'unavailable' : |
---|
| 434 | this.status = 'type='+pType; |
---|
| 435 | this.statusFlag = pType; |
---|
| 436 | imgStatus = pType; |
---|
| 437 | break; |
---|
| 438 | case 'custom' : |
---|
| 439 | var custom = prompt('Personalize seu Status : '); |
---|
| 440 | if(custom) |
---|
| 441 | this.status = 'status='+custom; |
---|
| 442 | else |
---|
| 443 | return; |
---|
| 444 | } |
---|
| 445 | |
---|
| 446 | cookies_im.setCookie('status', this.status, null); |
---|
| 447 | function handler_presence(XmlData) |
---|
| 448 | { |
---|
| 449 | if(imgStatus != null) |
---|
| 450 | func.byId('im_status_src').src = eval('im_' + imgStatus + '.src'); |
---|
| 451 | } |
---|
| 452 | this.conn.go('$this.Ujabber.setPresence', {'request' : handler_presence}, this.status); |
---|
| 453 | }, |
---|
| 454 | |
---|
| 455 | "remove" : function(pJid) |
---|
| 456 | { |
---|
| 457 | if(confirm('Deseja excluir o contato ' + pJid + ' ?')) |
---|
| 458 | { |
---|
| 459 | function handler_remove(XmlData) |
---|
| 460 | { |
---|
| 461 | if(XmlData == "OK") |
---|
| 462 | { |
---|
| 463 | func.byId(pJid).parentNode.removeChild(func.byId(pJid)); |
---|
| 464 | function handler(Xmldata){}; |
---|
| 465 | con.go('$this.Ujabber.setPresence', {'request':handler},'type=unavailable'); |
---|
| 466 | var status = cookies_im.checkCookie('status'); |
---|
| 467 | im.status = status.substr(status.indexOf("=") + 1,status.length); |
---|
| 468 | setTimeout("im.presence(\'" + im.status + "\')",3000); |
---|
| 469 | } |
---|
| 470 | } |
---|
| 471 | this.conn.go('$this.Ujabber.removeContact',{'request':handler_remove},'jid='+pJid); |
---|
| 472 | } |
---|
| 473 | }, |
---|
| 474 | |
---|
| 475 | "remove_contact" : function(pElement) |
---|
| 476 | { |
---|
| 477 | var Jid = ""; |
---|
| 478 | |
---|
| 479 | if( func.byId(pElement).options.length > 0 ) |
---|
| 480 | for(var i=0; i < func.byId(pElement).options.length; i++) |
---|
| 481 | if( func.byId(pElement).options[i].selected == true ) |
---|
| 482 | Jid = func.byId(pElement).options[i].value; |
---|
| 483 | |
---|
| 484 | if(confirm('Deseja excluir o contato ' + Jid + ' ?')) |
---|
| 485 | { |
---|
| 486 | if( Jid && Jid != -1 ) |
---|
| 487 | { |
---|
| 488 | function handler_remove(XmlData) |
---|
| 489 | { |
---|
| 490 | if(XmlData == "OK") |
---|
| 491 | { |
---|
| 492 | func.byId(Jid).parentNode.removeChild(func.byId(Jid)); |
---|
| 493 | for(var i=0 ; i < func.byId(pElement).options.length; i++) |
---|
| 494 | { |
---|
| 495 | func.byId(pElement).options[i] = null; |
---|
| 496 | i--; |
---|
| 497 | } |
---|
| 498 | } |
---|
| 499 | im.get_contacts(); |
---|
| 500 | } |
---|
| 501 | this.conn.go('$this.Ujabber.removeContact',{'request':handler_remove},'jid='+Jid); |
---|
| 502 | } |
---|
| 503 | } |
---|
| 504 | }, |
---|
| 505 | |
---|
| 506 | "request_vcard" : function(pJid, pVcard) |
---|
| 507 | { |
---|
| 508 | this.vcard = pVcard; |
---|
| 509 | function handler_getVcard(XmlData){} |
---|
| 510 | this.conn.go('$this.Ujabber.getVcard',{'request':handler_getVcard},'jid='+pJid); |
---|
| 511 | }, |
---|
| 512 | |
---|
| 513 | "save_vcard" : function() |
---|
| 514 | { |
---|
| 515 | |
---|
| 516 | var xmlVcard = "<FN>" + func.byId('im_fn').value + "</FN>"; |
---|
| 517 | xmlVcard += "<NICKNAME>" + func.byId('im_nickname').value + "</NICKNAME>"; |
---|
| 518 | xmlVcard += "<ORG>"; |
---|
| 519 | xmlVcard += "<ORGNAME>" + func.byId('im_orgname').value + "</ORGNAME>"; |
---|
| 520 | xmlVcard += "<ORGUNIT>" + func.byId('im_orgunit').value + "</ORGUNIT>"; |
---|
| 521 | xmlVcard += "</ORG>"; |
---|
| 522 | xmlVcard += "<ROLE>" + func.byId('im_role').value + "</ROLE>"; |
---|
| 523 | xmlVcard += "<BDAY>" + func.byId('im_bday').value + "</BDAY>"; |
---|
| 524 | |
---|
| 525 | func.byId('im_layer_nickname').innerHTML = func.byId('im_nickname').value; |
---|
| 526 | |
---|
| 527 | function handler_savevcard(XmlData) |
---|
| 528 | { |
---|
| 529 | if( XmlData != "OK" ) |
---|
| 530 | alert('Vcard não cadastrado/atualizado !'); |
---|
| 531 | else |
---|
| 532 | alert('Vcard cadastrado/atualizado !'); |
---|
| 533 | } |
---|
| 534 | this.conn.go('$this.Ujabber.newVcard',{'request':handler_savevcard},"vcard="+xmlVcard); |
---|
| 535 | |
---|
| 536 | }, |
---|
| 537 | |
---|
| 538 | "set_preferences" : function() |
---|
| 539 | { |
---|
| 540 | var preferences = ""; |
---|
| 541 | var numbers = /^\d+$/; |
---|
| 542 | |
---|
| 543 | this.timeOut_im = 1; |
---|
| 544 | preferences = (func.byId('ch_offline').checked ) ? 'ch_offline:true;' : 'ch_offline:false;'; |
---|
| 545 | this.contacts_off_line = func.byId('ch_offline').checked; |
---|
| 546 | if(numbers.test(func.byId('time_xa_im').value) && func.byId('time_xa_im').value != "0") |
---|
| 547 | { |
---|
| 548 | preferences += "time_xa_im:" + func.byId('time_xa_im').value + ";"; |
---|
| 549 | this.timeOut_im = func.byId('time_xa_im').value; |
---|
| 550 | } |
---|
| 551 | else |
---|
| 552 | preferences += "time_xa_im:1;"; |
---|
| 553 | |
---|
| 554 | preferences += ( func.byId('rd_nm').checked ) ? 'rd_nm:true;' : 'rd_nm:false;'; |
---|
| 555 | this.notification_nm = ( func.byId('rd_nm').checked ) ? true : false; |
---|
| 556 | preferences += ( func.byId('rd_ch').checked ) ? 'rd_ch:true' : 'rd_ch:false'; |
---|
| 557 | this.notification_ch = ( func.byId('rd_ch').checked ) ? true : false; |
---|
| 558 | |
---|
| 559 | function handler_preferences(XmlData) |
---|
| 560 | { |
---|
| 561 | if(XmlData === "true") |
---|
| 562 | { |
---|
| 563 | cookies_im.setCookie('preferences_im', preferences, null); |
---|
| 564 | im.off_line(); |
---|
| 565 | alert('Preferências Salvas !'); |
---|
| 566 | } |
---|
| 567 | } |
---|
| 568 | this.conn.go('$this.db_im.set_preferences',{'request':handler_preferences},'preferences='+preferences); |
---|
| 569 | }, |
---|
| 570 | |
---|
| 571 | "set_timeOut" : function() |
---|
| 572 | { |
---|
| 573 | if( this.statusFlag === 'available') |
---|
| 574 | setTimeout("im.presence(\'xa\')",parseInt(im.timeOut_im)); |
---|
| 575 | }, |
---|
| 576 | |
---|
| 577 | "subscription" : function(pJid, pType) |
---|
| 578 | { |
---|
| 579 | function handler_request(XmlData) |
---|
| 580 | { |
---|
| 581 | if(XmlData != 1) |
---|
| 582 | alert(XmlData); |
---|
| 583 | } |
---|
| 584 | this.conn.go('$this.Ujabber.subscription',{'request':handler_request},"jid="+pJid+"&type="+pType); |
---|
| 585 | }, |
---|
| 586 | |
---|
| 587 | "update_nickname" : function(pJid) |
---|
| 588 | { |
---|
| 589 | var jid = pJid; |
---|
| 590 | var name = func.byId(pJid).getAttribute('idname'); |
---|
| 591 | var group = func.byId(pJid).getAttribute('idgroup'); |
---|
| 592 | cookies_im.setCookie('contacts', pJid + "=" + func.byId("img_"+ pJid).src, 1); |
---|
| 593 | |
---|
| 594 | if( value = prompt("Digite um novo apelido para : " + jid, "" )) |
---|
| 595 | { |
---|
| 596 | if(func.trim(value) != "" && value != null) |
---|
| 597 | { |
---|
| 598 | name = value; |
---|
| 599 | function handler_update_contact(XmlData) |
---|
| 600 | { |
---|
| 601 | if(XmlData != "OK") |
---|
| 602 | alert('Contato não atualizado !'); |
---|
| 603 | else |
---|
| 604 | { |
---|
| 605 | function handler(Xmldata){}; |
---|
| 606 | con.go('$this.Ujabber.setPresence', {'request':handler},'type=unavailable'); |
---|
| 607 | |
---|
| 608 | var status = cookies_im.checkCookie('status'); |
---|
| 609 | im.status = status.substr(status.indexOf("=") + 1,status.length); |
---|
| 610 | setTimeout("im.presence(\'" + im.status + "\')",3000); |
---|
| 611 | } |
---|
| 612 | } |
---|
| 613 | this.conn.go('$this.Ujabber.updateContact',{'request':handler_update_contact},"jid="+jid+"&name="+name+"&group="+group); |
---|
| 614 | } |
---|
| 615 | } |
---|
| 616 | }, |
---|
| 617 | |
---|
| 618 | "update_group" : function(pJid) |
---|
| 619 | { |
---|
| 620 | var jid = pJid; |
---|
| 621 | var name = func.byId(pJid).getAttribute('idname'); |
---|
| 622 | var group = func.byId(pJid).getAttribute('idgroup'); |
---|
| 623 | cookies_im.setCookie('contacts', pJid + "=" + func.byId("img_"+ pJid).src, 1); |
---|
| 624 | |
---|
| 625 | if( value = prompt("Digite um novo grupo para : " + jid, "" )) |
---|
| 626 | { |
---|
| 627 | if(func.trim(value) != "" && value != null) |
---|
| 628 | { |
---|
| 629 | group = value; |
---|
| 630 | function handler_update_contact(XmlData) |
---|
| 631 | { |
---|
| 632 | if(XmlData != "OK") |
---|
| 633 | alert('Contato não atualizado !'); |
---|
| 634 | else |
---|
| 635 | { |
---|
| 636 | function handler(Xmldata){}; |
---|
| 637 | con.go('$this.Ujabber.setPresence', {'request':handler},'type=unavailable'); |
---|
| 638 | var status = cookies_im.checkCookie('status'); |
---|
| 639 | im.status = status.substr(status.indexOf("=") + 1,status.length); |
---|
| 640 | setTimeout("im.presence(\'" + im.status + "\')",3000); |
---|
| 641 | } |
---|
| 642 | } |
---|
| 643 | this.conn.go('$this.Ujabber.updateContact',{'request':handler_update_contact},"jid="+jid+"&name="+name+"&group="+group); |
---|
| 644 | } |
---|
| 645 | } |
---|
| 646 | } |
---|
| 647 | } |
---|
| 648 | var im = new Im(); |
---|