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