[903] | 1 | // Instant Messenger |
---|
| 2 | // im_preferences.js |
---|
| 3 | |
---|
| 4 | function IM_Preferences() |
---|
| 5 | { |
---|
| 6 | this.save_vcard = ""; |
---|
| 7 | this.jid = false; |
---|
| 8 | this.im_timer_xa = ""; |
---|
| 9 | } |
---|
| 10 | |
---|
| 11 | /* |
---|
| 12 | * Add |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | IM_Preferences.prototype.Add_userLoad = function() |
---|
| 16 | { |
---|
| 17 | Templates.add_user(); |
---|
| 18 | this.SearchOrganizationsLdap(); |
---|
| 19 | var select_contact = document.getElementById('ImSelAddContact'); |
---|
| 20 | select_contact.innerHTML = ""; |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | IM_Preferences.prototype.SearchOrganizationsLdap = function() |
---|
| 24 | { |
---|
| 25 | var handler_organizations = function(data) |
---|
| 26 | { |
---|
| 27 | var data = func.interface(data); |
---|
| 28 | var select_org = document.getElementById('ImSelOrg'); |
---|
| 29 | if(select_org.options.length > 0) |
---|
| 30 | select_org.options.splice(0,select_org.options.length); |
---|
| 31 | var options = new Option("--Selecione -- ", -1, false, true); |
---|
| 32 | select_org[select_org.length] = options; |
---|
| 33 | |
---|
| 34 | for(var i in data){ |
---|
| 35 | var options = new Option(data[i], data[i], false, true); |
---|
| 36 | select_org[select_org.length] = options; |
---|
| 37 | } |
---|
| 38 | select_org[0].selected = true; |
---|
| 39 | } |
---|
| 40 | XMLTools.request('$this.ldap_im.list_organizations_ldap','GET',handler_organizations); |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | IM_Preferences.prototype.SearchContacts = function() |
---|
| 44 | { |
---|
| 45 | var select_org = document.getElementById('ImSelOrg'); |
---|
| 46 | var organization = ""; |
---|
| 47 | var span_load = document.getElementById('_span_load_im'); |
---|
| 48 | span_load.style.display = "block"; |
---|
| 49 | |
---|
| 50 | for(var i=0; i < select_org.options.length; i++){ |
---|
| 51 | if(select_org.options[i].selected == true){ |
---|
| 52 | organization = select_org.options[i].value; |
---|
| 53 | } |
---|
| 54 | } |
---|
| 55 | var handler_contacts = function(XMLdata) |
---|
| 56 | { |
---|
| 57 | var data = func.interface(XMLdata); |
---|
| 58 | var select_contact = document.getElementById('ImSelAddContact'); |
---|
| 59 | var text0 = document.getElementById('text0'); |
---|
| 60 | var text1 = document.getElementById('text1'); |
---|
| 61 | var content = ""; |
---|
| 62 | select_contact.innerHTML = ""; |
---|
| 63 | text0.value = ""; |
---|
| 64 | text1.value = ""; |
---|
| 65 | if(data) |
---|
| 66 | { |
---|
| 67 | for(var i in data) |
---|
| 68 | { |
---|
| 69 | var options = new Option(data[i].cn + " ( "+ data[i].mail + " )", data[i].mail + ";" + data[i].uid, false, false); |
---|
| 70 | select_contact[select_contact.length] = options; |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | span_load.style.display = "none"; |
---|
| 74 | } |
---|
| 75 | XMLTools.request('$this.contacts_im.list_contacts','POST',handler_contacts, 'ou='+organization); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | IM_Preferences.prototype.preenche = function() |
---|
| 79 | { |
---|
| 80 | var select = document.getElementById('ImSelAddContact'); |
---|
| 81 | if(select.options.length > 0){ |
---|
| 82 | for(var i=0; i < select.options.length; i++){ |
---|
| 83 | if(select.options[i].selected == true){ |
---|
| 84 | var email = select.options[i].value.substr(0,select.options[i].value.indexOf(';')); |
---|
| 85 | var uid = select.options[i].value.substr((select.options[i].value.indexOf(';')+1),select.options[i].value.length); |
---|
| 86 | document.getElementById('text0').value = email; |
---|
| 87 | document.getElementById('text1').value = select.options[i].value.substr(0,select.options[i].value.indexOf('@')); |
---|
| 88 | document.getElementById('text2').focus(); |
---|
| 89 | document.getElementById('text3').value = uid; |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | } |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | IM_Preferences.prototype.Add_user = function(pFunc) |
---|
| 96 | { |
---|
| 97 | var text0 = document.getElementById('text0'); |
---|
| 98 | var text1 = document.getElementById('text1'); |
---|
| 99 | var text2 = document.getElementById('text2'); |
---|
| 100 | var text3 = ( document.getElementById('text3') != null ) ? document.getElementById('text3') : false; |
---|
| 101 | |
---|
| 102 | var _this = this; |
---|
| 103 | var jid = text0.value; |
---|
| 104 | var subscription = ""; |
---|
| 105 | |
---|
| 106 | if(func.trim(text0.value) != "" && func.trim(text1.value) != "" && func.trim(text2.value) != "") |
---|
| 107 | { |
---|
| 108 | var handler_add_contact = function(data) |
---|
| 109 | { |
---|
| 110 | IM.vcards = false; |
---|
| 111 | IM.Vcard(); |
---|
| 112 | |
---|
| 113 | text0.value = ""; |
---|
| 114 | text1.value = ""; |
---|
| 115 | text2.value = ""; |
---|
| 116 | |
---|
| 117 | if(pFunc != 'divAddUser_im') |
---|
| 118 | { |
---|
| 119 | if(document.getElementById('im_cell_' + jid)) |
---|
| 120 | { |
---|
| 121 | var div_jid = document.getElementById('im_cell_' + jid); |
---|
| 122 | div_jid.parentNode.removeChild(div_jid); |
---|
| 123 | |
---|
| 124 | for(var i in IM.UsersNot) |
---|
| 125 | if( IM.UsersNot[i] === jid ) |
---|
| 126 | IM.UsersNot.splice(i,1); |
---|
| 127 | |
---|
| 128 | im_win.windowClose(pFunc); |
---|
| 129 | Subscription.subscribed(jid); |
---|
| 130 | IM.setStatus(statusFlag); |
---|
| 131 | setTimeout('Subscription.subscribe("'+jid+'")',2000); |
---|
| 132 | } |
---|
| 133 | } |
---|
| 134 | else |
---|
| 135 | { |
---|
| 136 | Templates.Status_AddUser(); |
---|
| 137 | setTimeout("Templates.Status_AddUser();",3000); |
---|
| 138 | } |
---|
| 139 | if( IM.UsersNot.length == 0 ) |
---|
| 140 | im_win.windowClose('divFormAuthUser_im'); |
---|
| 141 | } |
---|
| 142 | var name = text1.value; |
---|
| 143 | var group = text2.value; |
---|
| 144 | if(text3){ |
---|
| 145 | var email = text3.value + "@" + text0.value.substr((text0.value.indexOf('@')+1),text0.value.length); |
---|
| 146 | }else{ |
---|
| 147 | var email = text0.value; |
---|
| 148 | } |
---|
| 149 | XMLTools.request('$this.Ujabber.addContacts','POST',handler_add_contact,"email="+email+"&name="+name+"&group="+group); |
---|
| 150 | }else{ |
---|
| 151 | alert("Informe todos os campos!"); |
---|
| 152 | } |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | IM_Preferences.prototype.AcceptRequestUser = function(pJid) |
---|
| 156 | { |
---|
| 157 | Templates.AcceptRequestUser(); |
---|
| 158 | document.getElementById('text0').value = pJid; |
---|
| 159 | document.getElementById('text1').value = pJid.substr(0,pJid.indexOf('@')); |
---|
| 160 | document.getElementById('text1').focus(); |
---|
| 161 | document.getElementById('text1').select(); |
---|
| 162 | document.getElementById('span0').innerHTML = pJid.substr(0,pJid.indexOf('@')); |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | /* |
---|
| 166 | * Remove |
---|
| 167 | */ |
---|
| 168 | |
---|
| 169 | IM_Preferences.prototype.RemoveContact = function(pJid) |
---|
| 170 | { |
---|
| 171 | var _this = this; |
---|
| 172 | if(!pJid) |
---|
| 173 | { |
---|
| 174 | var sel_box = document.getElementById('sel_contact'); |
---|
| 175 | for(var i=0; i < sel_box.options.length; i++) |
---|
| 176 | { |
---|
| 177 | if(sel_box[i].selected && sel_box.options[i].value != 0) |
---|
| 178 | pJid = sel_box.options[i].value; |
---|
| 179 | } |
---|
| 180 | } |
---|
| 181 | if( pJid ) |
---|
| 182 | { |
---|
| 183 | if( confirm('Deseja remover o contato : ' + pJid) ) |
---|
| 184 | { |
---|
| 185 | IM.vcards = false; |
---|
| 186 | IM.Vcard(); |
---|
| 187 | var div_child = document.getElementById(pJid); |
---|
| 188 | div_child.parentNode.removeChild(div_child); |
---|
| 189 | _this.ComboRemoveUser(_this.LoadJids()); |
---|
| 190 | var handler_remove_contact = function(data) |
---|
| 191 | { |
---|
| 192 | }; |
---|
| 193 | XMLTools.request('$this.Ujabber.removeContact','POST',handler_remove_contact,"jid="+pJid); |
---|
| 194 | } |
---|
| 195 | }else |
---|
| 196 | alert('Opção inválida !!'); |
---|
| 197 | } |
---|
| 198 | |
---|
| 199 | IM_Preferences.prototype.Remove_userLoad = function() |
---|
| 200 | { |
---|
| 201 | Templates.remove_user(); |
---|
| 202 | var div_allg = document.getElementById('all_groups'); |
---|
| 203 | var _this = this; |
---|
| 204 | _this.ComboRemoveUser(_this.LoadJids()); |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | IM_Preferences.prototype.ComboRemoveUser = function(pJids) |
---|
| 208 | { |
---|
| 209 | var sel_box = document.getElementById('sel_contact'); |
---|
| 210 | |
---|
| 211 | if( document.getElementById('sel_contact') != null ) |
---|
| 212 | { |
---|
| 213 | if( sel_box.options.length > 0 ) |
---|
| 214 | { |
---|
| 215 | for(var i=0; i < sel_box.options.length; i++) |
---|
| 216 | { |
---|
| 217 | sel_box.options[i] = null; |
---|
| 218 | i--; |
---|
| 219 | } |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | var opt = new Option('--- Selecione ---',0,false,true); |
---|
| 223 | sel_box[sel_box.length] = opt; |
---|
| 224 | for(var i in pJids) |
---|
| 225 | { |
---|
| 226 | var opt = new Option(pJids[i].substr(0,pJids[i].indexOf('@')), pJids[i], false, true); |
---|
| 227 | sel_box[sel_box.length] = opt; |
---|
| 228 | } |
---|
| 229 | sel_box[0].selected = true; |
---|
| 230 | } |
---|
| 231 | } |
---|
| 232 | |
---|
| 233 | IM_Preferences.prototype.DenyRequestUser = function(pJid) |
---|
| 234 | { |
---|
| 235 | if(confirm('Deseja excluir ' + pJid + '?')) |
---|
| 236 | { |
---|
| 237 | var div_jid = document.getElementById('im_cell_' + pJid); |
---|
| 238 | div_jid.parentNode.removeChild(div_jid); |
---|
| 239 | |
---|
| 240 | for(var i in IM.UsersNot) |
---|
| 241 | if(IM.UsersNot[i] === pJid) |
---|
| 242 | IM.UsersNot.splice(i,1); |
---|
| 243 | |
---|
| 244 | if( IM.UsersNot.length == 0 ) |
---|
| 245 | im_win.windowClose('divFormAuthUser_im'); |
---|
| 246 | |
---|
| 247 | var handler_denyrequest = function(data) |
---|
| 248 | { |
---|
| 249 | }; |
---|
| 250 | XMLTools.request('$this.Ujabber.unsubscribe','POST',handler_denyrequest,'jid='+pJid); |
---|
| 251 | } |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | /* |
---|
| 255 | * LoadJids |
---|
| 256 | */ |
---|
| 257 | |
---|
| 258 | IM_Preferences.prototype.LoadJids = function() |
---|
| 259 | { |
---|
| 260 | var div_allg = document.getElementById('all_groups'); |
---|
| 261 | var elements = div_allg.firstChild; |
---|
| 262 | var jids = []; |
---|
| 263 | while ( elements ) |
---|
| 264 | { |
---|
| 265 | var childs = elements.firstChild; |
---|
| 266 | while( childs ) |
---|
| 267 | { |
---|
| 268 | if(childs.tagName == "DIV") |
---|
| 269 | jids[jids.length] = childs.id; |
---|
| 270 | childs = childs.nextSibling; |
---|
| 271 | } |
---|
| 272 | elements = elements.nextSibling; |
---|
| 273 | } |
---|
| 274 | jids.sort(); |
---|
| 275 | |
---|
| 276 | return jids; |
---|
| 277 | } |
---|
| 278 | |
---|
| 279 | /* |
---|
| 280 | * Update |
---|
| 281 | */ |
---|
| 282 | |
---|
| 283 | IM_Preferences.prototype.Update_ = function(pJid,pType) |
---|
| 284 | { |
---|
| 285 | var div_child = document.getElementById(pJid); |
---|
| 286 | var group = div_child.parentNode.id; |
---|
| 287 | var name = div_child.firstChild; |
---|
| 288 | name = name.nextSibling.nodeValue; |
---|
| 289 | |
---|
| 290 | if(pType) |
---|
| 291 | { |
---|
| 292 | var action = prompt('Digite um novo apelido para : ' + pJid, " "); |
---|
| 293 | name = (action == "Apelido") ? "" : action ; |
---|
| 294 | }else{ |
---|
| 295 | var action = prompt('Digite um novo grupo para : ' + pJid , " "); |
---|
| 296 | group = action ; |
---|
| 297 | } |
---|
| 298 | |
---|
| 299 | if( action != "" && action != null) |
---|
| 300 | { |
---|
| 301 | var handler_update_contact = function(XMLdata) |
---|
| 302 | { |
---|
| 303 | }; |
---|
| 304 | XMLTools.request('$this.Ujabber.updateContact','POST',handler_update_contact,"jid="+pJid+"&name="+name+"&group="+group); |
---|
| 305 | } |
---|
| 306 | } |
---|
| 307 | |
---|
| 308 | IM_Preferences.prototype.Update_Group = function(pJid) |
---|
| 309 | { |
---|
| 310 | this.Update_(pJid,false); |
---|
| 311 | } |
---|
| 312 | |
---|
| 313 | IM_Preferences.prototype.Update_NickName = function(pJid) |
---|
| 314 | { |
---|
| 315 | this.Update_(pJid,true); |
---|
| 316 | } |
---|
| 317 | |
---|
| 318 | /* |
---|
| 319 | * Vcard |
---|
| 320 | */ |
---|
| 321 | |
---|
| 322 | IM_Preferences.prototype.vCardInit = function() |
---|
| 323 | { |
---|
| 324 | var _this = this; |
---|
| 325 | var nickname = ""; |
---|
| 326 | var message = ""; |
---|
| 327 | var vcards = ""; |
---|
| 328 | |
---|
| 329 | var handler_getId = function(_XMLdata) |
---|
| 330 | { |
---|
| 331 | var jid = _XMLdata.getElementsByTagName("retorno").item(0); |
---|
| 332 | jid = jid.firstChild.nodeValue; |
---|
| 333 | _this.jid = jid; |
---|
| 334 | |
---|
| 335 | if((vcards = _this.vCardLoad(jid))) |
---|
| 336 | { |
---|
| 337 | nickname = vcards.substr(vcards.indexOf('NICKNAME'),vcards.length); |
---|
| 338 | nickname = nickname.substr(0,nickname.indexOf('|')); |
---|
| 339 | nickname = nickname.substr(nickname.indexOf(':') + 1 , nickname.length); |
---|
| 340 | |
---|
| 341 | message = vcards.substr(vcards.indexOf('DESC'),vcards.length); |
---|
| 342 | message = message.substr(0,message.indexOf('|')); |
---|
| 343 | message = message.substr(message.indexOf(':') + 1 , message.length); |
---|
| 344 | } |
---|
| 345 | |
---|
| 346 | nickname = (func.trim(nickname) != "" ) ? nickname : _this.jid ; |
---|
| 347 | message = (func.trim(message) != "" ) ? message : "Sua Mensagem"; |
---|
| 348 | IM.custom_message = message; |
---|
| 349 | |
---|
| 350 | var span_nick = document.getElementById('span_nickname'); |
---|
| 351 | span_nick.innerHTML = ( nickname ) ? "<b>" + decodeURI(nickname.substring(0,15)) + "</b>" : "<b>" + IM.get_lang('Nickname') + "</b>"; |
---|
| 352 | } |
---|
| 353 | XMLTools.request('$this.Ujabber.getJid','GET',handler_getId); |
---|
| 354 | } |
---|
| 355 | |
---|
| 356 | IM_Preferences.prototype.vCardLoad = function(Jid) |
---|
| 357 | { |
---|
| 358 | var div_jid = document.getElementById("vcard_" + Jid); |
---|
| 359 | var strg = div_jid.innerHTML; |
---|
| 360 | var elements = div_jid.firstChild; |
---|
| 361 | var exp , tag = ''; |
---|
| 362 | |
---|
| 363 | while ( elements ) |
---|
| 364 | { |
---|
| 365 | if(elements.tagName != undefined && elements.tagName.substr(0,1) != "/" ) |
---|
| 366 | { |
---|
| 367 | tag = elements.tagName; |
---|
| 368 | exp = eval('/<'+tag+'>/gi'); |
---|
| 369 | strg = strg.replace(exp, tag + " : " ); |
---|
| 370 | exp = eval('/<\\/'+tag+'>/gi'); |
---|
| 371 | strg = strg.replace(exp, " | "); |
---|
| 372 | } |
---|
| 373 | elements = elements.nextSibling; |
---|
| 374 | } |
---|
| 375 | |
---|
| 376 | return strg; |
---|
| 377 | } |
---|
| 378 | |
---|
| 379 | IM_Preferences.prototype.vCard = function() |
---|
| 380 | { |
---|
| 381 | if(!this.jid){ |
---|
| 382 | alert('Carregando !!'); |
---|
| 383 | }else{ |
---|
| 384 | var div_jid = document.getElementById("vcard_" + this.jid); |
---|
| 385 | var strg = div_jid.innerHTML; |
---|
| 386 | Templates.information_user(strg); |
---|
| 387 | } |
---|
| 388 | } |
---|
| 389 | |
---|
| 390 | IM_Preferences.prototype.vCardLoad_Contact = function(pJid) |
---|
| 391 | { |
---|
| 392 | if(!this.jid){ |
---|
| 393 | alert('Carregando !!'); |
---|
| 394 | }else{ |
---|
| 395 | if(document.getElementById('vcard_' + pJid) != null) |
---|
| 396 | { |
---|
| 397 | var vcards = document.getElementById('vcard_' + pJid); |
---|
| 398 | Templates.information_Contact(vcards.innerHTML); |
---|
| 399 | }else |
---|
| 400 | alert('Vcard não carregado!'); |
---|
| 401 | } |
---|
| 402 | } |
---|
| 403 | |
---|
| 404 | IM_Preferences.prototype.vCardAdd = function() |
---|
| 405 | { |
---|
| 406 | var Nvcard = new Array('FN','NICKNAME','ORGNAME','ORGUNIT','ROLE','BDAY','DESC'); |
---|
| 407 | var vcard = ""; |
---|
| 408 | var new_vcard = ""; |
---|
| 409 | var value = ""; |
---|
| 410 | for(var i in Nvcard) |
---|
| 411 | { |
---|
| 412 | if( Nvcard[i] === 'NICKNAME' ) |
---|
| 413 | { |
---|
| 414 | var nn = ( func.trim(document.getElementById(Nvcard[i]).value) != "") ? document.getElementById(Nvcard[i]).value : this.jid; |
---|
| 415 | document.getElementById('span_nickname').innerHTML = "<b>" + nn.substring(0,15) + "</b>"; |
---|
| 416 | } |
---|
| 417 | |
---|
| 418 | value = document.getElementById(Nvcard[i]).value; |
---|
| 419 | new_vcard += '<'+Nvcard[i]+'>'+value+'</'+Nvcard[i]+'>'; |
---|
| 420 | value = (func.trim(value) != "") ? value : ""; |
---|
| 421 | vcard += value + "_vkrd_"; |
---|
| 422 | } |
---|
| 423 | |
---|
| 424 | document.getElementById("vcard_" + this.jid).innerHTML = new_vcard; |
---|
| 425 | vcard = vcard.substr(0,vcard.length - 6 ); |
---|
| 426 | |
---|
| 427 | var handler_vcard_add = function(XMLdata) |
---|
| 428 | { |
---|
| 429 | }; |
---|
| 430 | XMLTools.request('$this.Ujabber.newVcard','POST',handler_vcard_add,"vcard="+escape(vcard)); |
---|
| 431 | alert('Informações Cadastradas / Adicionadas !!!'); |
---|
| 432 | im_win.windowClose('divInfoUser_im'); |
---|
| 433 | } |
---|
| 434 | |
---|
| 435 | /* |
---|
| 436 | * IM_Preferences |
---|
| 437 | */ |
---|
| 438 | |
---|
| 439 | IM_Preferences.prototype.yourPreferences = function() |
---|
| 440 | { |
---|
| 441 | Templates.yourPreferences(); |
---|
| 442 | } |
---|
| 443 | |
---|
| 444 | IM_Preferences.prototype.SetYourPreferences = function() |
---|
| 445 | { |
---|
| 446 | var preferences = ""; |
---|
| 447 | preferences = ( func.byId('ch_offline').checked ) ? 'ch_offline:true;' : 'ch_offline:false;'; |
---|
| 448 | if( func.byId('in_time').value ) |
---|
| 449 | { |
---|
| 450 | var numbers = /^\d+$/; |
---|
| 451 | if(numbers.test(func.byId('in_time').value) && func.byId('in_time').value != "0") |
---|
| 452 | var minutes = func.byId('in_time').value; |
---|
| 453 | else |
---|
| 454 | { |
---|
| 455 | alert('Informe valores válidos !'); |
---|
| 456 | func.byId('in_time').focus(); |
---|
| 457 | return false; |
---|
| 458 | } |
---|
| 459 | } |
---|
| 460 | |
---|
| 461 | this.im_timer_xa = func.byId('in_time').value; |
---|
| 462 | preferences += ( func.trim(func.byId('in_time').value )) ? 'in_time:' + func.byId('in_time').value + ";" : 'in_time:0;'; |
---|
| 463 | preferences += ( func.byId('rd_nm').checked ) ? 'rd_nm:true;' : 'rd_nm:false;'; |
---|
| 464 | preferences += ( func.byId('rd_ch').checked ) ? 'rd_ch:true' : 'rd_ch:false'; |
---|
| 465 | IM.userPrefe = preferences; |
---|
| 466 | |
---|
| 467 | var handler_preferences = function(XMLdata) |
---|
| 468 | { |
---|
| 469 | var data = XMLdata.getElementsByTagName('retorno').item(0); |
---|
| 470 | data = eval(data.firstChild.nodeValue); |
---|
| 471 | if(data) |
---|
| 472 | { |
---|
| 473 | IM.Contacts_Offline(); |
---|
| 474 | alert('Preferências salvas !'); |
---|
| 475 | } |
---|
| 476 | }; |
---|
| 477 | XMLTools.request('$this.db_im.set_preferences','POST',handler_preferences,'preferences='+preferences); |
---|
| 478 | } |
---|
| 479 | |
---|
| 480 | IM_Preferences.prototype.GetYourPreferences = function() |
---|
| 481 | { |
---|
| 482 | var _this = this; |
---|
| 483 | if(!IM.userPrefe) |
---|
| 484 | { |
---|
| 485 | var handler_getPreferences = function(XMLdata) |
---|
| 486 | { |
---|
| 487 | var data = XMLdata.getElementsByTagName('retorno').item(0); |
---|
| 488 | data = data.firstChild.nodeValue; |
---|
| 489 | IM.userPrefe = data; |
---|
| 490 | _this.TimerXa(_this.LoadPreferences('in_time')); |
---|
| 491 | } |
---|
| 492 | XMLTools.request('$this.db_im.get_preferences','GET',handler_getPreferences); |
---|
| 493 | } |
---|
| 494 | } |
---|
| 495 | |
---|
| 496 | IM_Preferences.prototype.LoadPreferences = function(pElement) |
---|
| 497 | { |
---|
| 498 | var preferences_im = IM.userPrefe; |
---|
| 499 | |
---|
| 500 | while( preferences_im !== "") |
---|
| 501 | { |
---|
| 502 | var values = ""; |
---|
| 503 | var value = ""; |
---|
| 504 | if(value = preferences_im.substr(0,preferences_im.indexOf(';'))) |
---|
| 505 | { |
---|
| 506 | values = value + '\n'; |
---|
| 507 | preferences_im = preferences_im.replace(value,''); |
---|
| 508 | } |
---|
| 509 | if(preferences_im.substr(0,1) == ";"){ |
---|
| 510 | preferences_im = preferences_im.substr(1,preferences_im.length); |
---|
| 511 | }else{ |
---|
| 512 | values = preferences_im + '\n'; |
---|
| 513 | preferences_im = ''; |
---|
| 514 | } |
---|
| 515 | |
---|
| 516 | var ele = values.substr(0,values.indexOf(':')); |
---|
| 517 | var val = values.substr((values.indexOf(':')+1),values.length); |
---|
| 518 | |
---|
| 519 | if(ele == pElement) |
---|
| 520 | return val; |
---|
| 521 | |
---|
| 522 | if((document.getElementById(ele)!= null) && (document.getElementById(ele).type == 'text')) |
---|
| 523 | document.getElementById(ele).value = val; |
---|
| 524 | else |
---|
| 525 | if(document.getElementById(ele) != null) |
---|
| 526 | document.getElementById(ele).checked = eval(val); |
---|
| 527 | } |
---|
| 528 | } |
---|
| 529 | |
---|
| 530 | /* |
---|
| 531 | * Estado de Ausente Automático |
---|
| 532 | */ |
---|
| 533 | |
---|
| 534 | IM_Preferences.prototype.TimerXa = function(pTimer) |
---|
| 535 | { |
---|
| 536 | this.im_timer_xa = pTimer; |
---|
| 537 | _awayTimer = setTimeout("IM.setAway()", parseInt(pTimer) * 60000 ); |
---|
| 538 | } |
---|
| 539 | |
---|
| 540 | /* |
---|
| 541 | * Detalhes do Contato para Autorização |
---|
| 542 | */ |
---|
| 543 | |
---|
| 544 | IM_Preferences.prototype.Info_Contact = function(pJid) |
---|
| 545 | { |
---|
| 546 | var element = "_span_not_" + pJid; |
---|
| 547 | var uid = pJid.substr(0,pJid.indexOf('@')); |
---|
| 548 | var handler_ldap = function(data) |
---|
| 549 | { |
---|
| 550 | var data = func.interface(data); |
---|
| 551 | var XMLinfoLdap = ""; |
---|
| 552 | if(data) |
---|
| 553 | { |
---|
| 554 | XMLinfoLdap = '<info_user>'; |
---|
| 555 | for(var i in data) |
---|
| 556 | XMLinfoLdap += '<item lang_name="'+IM.get_lang('Name')+'" name="'+ data[i].cn +'" lang_email="'+IM.get_lang('E-mail')+'" email="'+ data[i].mail +'" />'; |
---|
| 557 | XMLinfoLdap += '</info_user>'; |
---|
| 558 | } |
---|
| 559 | im_menu_action.menu(element, parse_XmlXsl(XMLinfoLdap,'info_contact_ldap.xsl')); |
---|
| 560 | if(document.getElementById('im_span_avatar') != null) |
---|
| 561 | { |
---|
| 562 | var span = document.getElementById('im_span_avatar'); |
---|
| 563 | var img = func.newEl('img'); |
---|
| 564 | func.confEl(img, 'id', pJid + '_avatar'); |
---|
| 565 | func.confEl(img, 'src', img_photo.src); |
---|
| 566 | func.confEl(img, 'style', 'height:65px;width:60px;align:right;'); |
---|
| 567 | span.appendChild(img); |
---|
| 568 | // Foto Ldap; |
---|
| 569 | im_win.get_photo_ldap(pJid); |
---|
| 570 | } |
---|
| 571 | } |
---|
| 572 | XMLTools.request('$this.ldap_im.info_user','POST',handler_ldap,'uid='+uid); |
---|
| 573 | } |
---|
| 574 | |
---|
| 575 | // Build Object |
---|
| 576 | var IM_Preferences = new IM_Preferences(); |
---|