Changeset 55 for trunk/instant_messenger/js/im_preferences.js
- Timestamp:
- 08/16/07 08:06:05 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/instant_messenger/js/im_preferences.js
r41 r55 2 2 // im_preferences.js 3 3 4 function Preferences()4 function IM_Preferences() 5 5 { 6 6 this.save_vcard = ""; 7 this.jid = false; 7 8 } 8 9 … … 11 12 */ 12 13 13 Preferences.prototype.Add_userLoad = function()14 IM_Preferences.prototype.Add_userLoad = function() 14 15 { 15 16 Templates.add_user(); … … 19 20 } 20 21 21 Preferences.prototype.SearchOrganizationsLdap = function() 22 { 23 var handler_organizations = function(data){ 22 IM_Preferences.prototype.SearchOrganizationsLdap = function() 23 { 24 var handler_organizations = function(data) 25 { 26 var data = func.interface(data); 24 27 var select_org = document.getElementById('ImSelOrg'); 25 28 if(select_org.options.length > 0) … … 34 37 select_org[0].selected = true; 35 38 } 36 cIM.cExecute("$this.ldap_im.list_organizations_ldap",handler_organizations);37 } 38 39 Preferences.prototype.SearchContacts = function()39 XMLTools.request('$this.ldap_im.list_organizations_ldap','POST',handler_organizations); 40 } 41 42 IM_Preferences.prototype.SearchContacts = function() 40 43 { 41 44 var select_org = document.getElementById('ImSelOrg'); 42 var select_contact = document.getElementById('ImSelAddContact');43 45 var organization = ""; 44 46 var span_load = document.getElementById('_span_load_im'); 45 span_load.style. visibility = "visible";46 47 span_load.style.display = "block"; 48 47 49 for(var i=0; i < select_org.options.length; i++){ 48 50 if(select_org.options[i].selected == true){ … … 50 52 } 51 53 } 52 var handler_contacts = function(data){ 54 var handler_contacts = function(data) 55 { 56 var data = func.interface(data); 53 57 var select_contact = document.getElementById('ImSelAddContact'); 54 58 var text0 = document.getElementById('text0'); … … 58 62 text0.value = ""; 59 63 text1.value = ""; 60 61 if( data.length > 0 ){ 62 for(var i in data){ 63 if(data[i].cn != ""){ 64 var options = new Option(data[i].cn + " ( "+ data[i].mail + " )", data[i].mail + ";" + data[i].uid, false, false); 65 select_contact[select_contact.length] = options; 66 } 64 if(data){ 65 for(var i in data) 66 { 67 var options = new Option(data[i].cn + " ( "+ data[i].mail + " )", data[i].mail + ";" + data[i].uid, false, false); 68 select_contact[select_contact.length] = options; 67 69 } 68 70 } 69 70 span_load.style.visibility = "hidden"; 71 } 72 cIM.cExecute("$this.contacts_im.list_contacts", handler_contacts,"ou="+organization); 73 74 } 75 76 Preferences.prototype.preenche = function() 71 span_load.style.display = "none"; 72 } 73 XMLTools.request('$this.contacts_im.list_contacts','POST',handler_contacts, 'ou='+organization); 74 } 75 76 IM_Preferences.prototype.preenche = function() 77 77 { 78 78 var select = document.getElementById('ImSelAddContact'); … … 83 83 var uid = select.options[i].value.substr((select.options[i].value.indexOf(';')+1),select.options[i].value.length); 84 84 document.getElementById('text0').value = email; 85 document.getElementById('text1').value = email.substr(0,email.indexOf('@'));86 document.getElementById('text2').focus(); 87 document.getElementById('text3').value = uid; 85 document.getElementById('text1').value = select.options[i].value.substr(0,select.options[i].value.indexOf('@')); 86 document.getElementById('text2').focus(); 87 document.getElementById('text3').value = uid; 88 88 } 89 89 } … … 91 91 } 92 92 93 Preferences.prototype.Add_user = function(pFunc)93 IM_Preferences.prototype.Add_user = function(pFunc) 94 94 { 95 95 var text0 = document.getElementById('text0'); 96 96 var text1 = document.getElementById('text1'); 97 97 var text2 = document.getElementById('text2'); 98 var text3 = ( document.getElementById('text3') != null) ? document.getElementById('text3') : false;99 98 var text3 = ( document.getElementById('text3') != null ) ? document.getElementById('text3') : false; 99 100 100 var _this = this; 101 101 var jid = text0.value; 102 102 var subscription = ""; 103 103 104 if(func.trim(text0.value) != "" && func.trim(text1.value) != "" && func.trim(text2.value) != ""){ 105 var handler_add_contact = function(data){ 106 if(data){ 107 text0.value = ""; 108 text1.value = ""; 109 text2.value = ""; 110 if(pFunc != 'divAddUser_im') 104 if(func.trim(text0.value) != "" && func.trim(text1.value) != "" && func.trim(text2.value) != "") 105 { 106 var handler_add_contact = function(data) 107 { 108 IM.vcards = false; 109 IM.requireVcard(); 110 111 text0.value = ""; 112 text1.value = ""; 113 text2.value = ""; 114 if(pFunc != 'divAddUser_im') 115 { 116 if(document.getElementById('im_cell_' + jid)) 117 { 118 var div_jid = document.getElementById('im_cell_' + jid); 119 div_jid.parentNode.removeChild(div_jid); 120 121 for(var i in IM.UsersNot) 122 if( IM.UsersNot[i] === jid ) 123 IM.UsersNot.splice(i,1); 124 111 125 im_win.windowClose(pFunc); 112 IM.UpdateContacts(); 113 _this.Refresh_Screen(jid); 126 Subscription.subscribed(jid); 127 IM.setStatus(statusFlag); 128 setTimeout('Subscription.subscribe("'+jid+'")',2000); 129 } 114 130 } 115 } 116 var name = url_encode(encodeURI(text1.value)); 117 var group = url_encode(encodeURI(text2.value)); 118 if(pFunc == 'divAddUser_im') 119 subscription = "none"; 120 else 121 subscription = "to"; 131 132 if( IM.UsersNot.length == 0 ) 133 im_win.windowClose('divFormAuthUser_im'); 134 } 135 var name = text1.value; 136 var group = text2.value; 122 137 if(text3){ 123 138 var email = text3.value + "@" + text0.value.substr((text0.value.indexOf('@')+1),text0.value.length); … … 125 140 var email = text0.value; 126 141 } 127 cIM.cExecute("$this.Ujabber.AddNewContacts",handler_add_contact,"email="+email+"&name="+name+"&group="+group+"&subscription="+subscription);142 XMLTools.request('$this.Ujabber.addContacts','POST',handler_add_contact,"email="+email+"&name="+name+"&group="+group); 128 143 }else{ 129 144 alert("Informe todos os campos!"); 130 145 } 131 146 } 147 148 IM_Preferences.prototype.AcceptRequestUser = function(pJid) 149 { 150 Templates.AcceptRequestUser(); 151 document.getElementById('text0').value = pJid; 152 document.getElementById('text1').value = pJid.substr(0,pJid.indexOf('@')); 153 document.getElementById('text1').focus(); 154 document.getElementById('text1').select(); 155 document.getElementById('span0').innerHTML = pJid.substr(0,pJid.indexOf('@')); 156 } 132 157 133 158 /* 134 159 * Remove 135 160 */ 136 137 Preferences.prototype.Remove_userLoad = function() 161 162 IM_Preferences.prototype.RemoveContact = function(pJid) 163 { 164 var _this = this; 165 if(!pJid) 166 { 167 var sel_box = document.getElementById('sel_contact'); 168 for(var i=0; i < sel_box.options.length; i++) 169 { 170 if(sel_box[i].selected && sel_box.options[i].value != 0) 171 pJid = sel_box.options[i].value; 172 } 173 } 174 if( pJid ) 175 { 176 if( confirm('Deseja remover o contato : ' + pJid) ) 177 { 178 IM.vcards = false; 179 IM.requireVcard(); 180 var div_child = document.getElementById(pJid); 181 div_child.parentNode.removeChild(div_child); 182 _this.ComboRemoveUser(_this.LoadJids()); 183 var handler_remove_contact = function(data) 184 { 185 }; 186 XMLTools.request('$this.Ujabber.removeContact','POST',handler_remove_contact,"jid="+pJid); 187 } 188 }else 189 alert('Opção inválida !!'); 190 } 191 192 IM_Preferences.prototype.Remove_userLoad = function() 138 193 { 139 194 Templates.remove_user(); 140 var sel_contact = document.getElementById('sel_contact'); 141 if(sel_contact.options.length > 0) 142 sel_contact.options.splice(0,sel_contact.options.length); 143 var opt = new Option("-- "+IM.get_lang('Choice Contact')+" -- ","0",true,true); 144 sel_contact.options[sel_contact.length] = opt; 145 146 for(var i=1; i < IM.array_users.length; i++){ 147 if(decodeURI(IM.array_users[i].name) != ""){ 148 opt = new Option(decodeURI(IM.array_users[i].name),IM.array_users[i].jid, false, false); 149 sel_contact.options[sel_contact.length] = opt; 150 }else{ 151 name = IM.array_users[i].jid.substr(0,IM.array_users[i].jid.indexOf('@')); 152 opt = new Option(name,IM.array_users[i].jid, false, false); 153 sel_contact.options[sel_contact.length] = opt; 154 } 155 } 156 } 157 158 Preferences.prototype.Remove_user = function() 159 { 195 var div_allg = document.getElementById('all_groups'); 160 196 var _this = this; 161 var sel_contact = document.getElementById('sel_contact'); 162 for(var i=0; i < sel_contact.options.length; i++){ 163 if(sel_contact[i].selected && sel_contact.options[i].value != 0){ 164 if(confirm("Excluir o contato " + sel_contact.options[i].innerHTML + "?")){ 165 var in_el = sel_contact.options[i].innerHTML; 166 for(var j=1 ; j < IM.array_users.length; j++){ 167 var name = IM.array_users[j].jid.substr(0,IM.array_users[j].jid.indexOf('@')); 168 if(decodeURI(IM.array_users[j].name) == in_el || name == in_el){ 169 var handler_remove_contact = function(data){ 170 if(!data){ 171 alert(data); 172 return false; 173 } 174 setTimeout("IM.UpdateContacts()",1000); 175 } 176 cIM.cExecute("$this.Ujabber.RosterRemoveUser",handler_remove_contact,"jid="+sel_contact.options[i].value); 177 IM.array_users.splice(j,1); 178 _this.ComboRemove(); 179 j--; 180 } 181 } 197 _this.ComboRemoveUser(_this.LoadJids()); 198 } 199 200 IM_Preferences.prototype.ComboRemoveUser = function(pJids) 201 { 202 var sel_box = document.getElementById('sel_contact'); 203 204 if( document.getElementById('sel_contact') != null ) 205 { 206 if( sel_box.options.length > 0 ) 207 { 208 for(var i=0; i < sel_box.options.length; i++) 209 { 210 sel_box.options[i] = null; 211 i--; 182 212 } 183 213 } 184 } 185 } 186 187 Preferences.prototype.ComboRemove = function() 188 { 189 var sel_contact = document.getElementById('sel_contact'); 190 if(sel_contact.length > 0 ){ 191 for(var i=0; i < sel_contact.options.length; i++){ 192 sel_contact.options[i] = null; 193 i--; 194 } 195 } 196 197 var opt = new Option("-- "+IM.get_lang('Choice Contact')+" -- ","0",true,true); 198 sel_contact.options[sel_contact.length] = opt; 199 for(var i=1; i < IM.array_users.length; i++){ 200 opt = new Option(decodeURI(IM.array_users[i].name),IM.array_users[i].jid, false, false); 201 sel_contact.options[sel_contact.length] = opt; 202 } 203 } 204 205 Preferences.prototype.Remove_Contact = function(pJid) 206 { 207 var _this = this; 208 for(var i=0; i < IM.array_users.length; i++){ 209 if(IM.array_users[i].jid == pJid){ 210 if(confirm("Excluir o contato " + decodeURI(IM.array_users[i].name) + "?")){ 211 var handler_remove_contact = function(data){ 212 if(!data){ 213 alert(data); 214 return; 215 }else{ 216 _this.Refresh_Screen(pJid); 217 IM.UpdateContacts(); 218 } 219 } 220 cIM.cExecute("$this.Ujabber.RosterRemoveUser",handler_remove_contact,"jid="+pJid); 221 } 222 return; 223 } 224 } 225 } 226 214 215 var opt = new Option('--- Selecione ---',0,false,true); 216 sel_box[sel_box.length] = opt; 217 for(var i in pJids) 218 { 219 var opt = new Option(pJids[i], pJids[i], false, true); 220 sel_box[sel_box.length] = opt; 221 } 222 sel_box[0].selected = true; 223 } 224 } 225 226 IM_Preferences.prototype.DenyRequestUser = function(pJid) 227 { 228 if(confirm('Deseja excluir ' + pJid + '?')) 229 { 230 var div_jid = document.getElementById('im_cell_' + pJid); 231 div_jid.parentNode.removeChild(div_jid); 232 233 for(var i in IM.UsersNot) 234 if(IM.UsersNot[i] === pJid) 235 IM.UsersNot.splice(i,1); 236 237 if( IM.UsersNot.length == 0 ) 238 im_win.windowClose('divFormAuthUser_im'); 239 240 var handler_denyrequest = function(data) 241 { 242 }; 243 XMLTools.request('$this.Ujabber.unsubscribe','POST',handler_denyrequest,'jid='+pJid); 244 } 245 } 246 247 /* 248 * LoadJids 249 */ 250 251 IM_Preferences.prototype.LoadJids = function() 252 { 253 var div_allg = document.getElementById('all_groups'); 254 var elements = div_allg.firstChild; 255 var jids = []; 256 while ( elements ) 257 { 258 var childs = elements.firstChild; 259 while( childs ) 260 { 261 if(childs.tagName == "DIV") 262 jids[jids.length] = childs.id; 263 childs = childs.nextSibling; 264 } 265 elements = elements.nextSibling; 266 } 267 jids.sort(); 268 269 return jids; 270 } 271 227 272 /* 228 273 * Update 229 274 */ 230 275 231 Preferences.prototype.updateLoad = function(pJid)276 IM_Preferences.prototype.Update_ = function(pJid,pType) 232 277 { 233 Jid = pJid; 234 Templates.update_user(); 235 document.getElementById('text0').value = Jid; 236 document.getElementById('span0').innerHTML = Jid.substr(0,Jid.indexOf('@')); 278 var div_child = document.getElementById(pJid); 279 var name = div_child.innerHTML.substr((div_child.innerHTML.indexOf('>') + 1 ),div_child.innerHTML.length); 280 var group = div_child.parentNode.id; 281 282 if(pType) 283 { 284 var action = prompt('Digite um novo apelido para : ' + pJid ); 285 name = action; 286 }else{ 287 var action = prompt('Digite um novo grupo para : ' + pJid ); 288 group = action; 289 } 290 291 if( action != "" && action != null) 292 { 293 var handler_update_contact = function(XMLdata) 294 { 295 }; 296 XMLTools.request('$this.Ujabber.updateContact','POST',handler_update_contact,"jid="+pJid+"&name="+name+"&group="+group); 297 } 298 237 299 } 238 239 Preferences.prototype.Update_ = function(pJid,pType) 240 { 241 var name = ""; 242 var group = ""; 243 var jid = pJid; 244 245 for(var i=1; i < IM.array_users.length; i++){ 246 if(IM.array_users[i].jid == pJid){ 247 name = decodeURI(IM.array_users[i].name); 248 group = decodeURI(IM.array_users[i].group); 249 } 250 } 251 252 if((name != "") && (group != "")){ 253 if(pType){ 254 var act = prompt("Digite um apelido para :" + pJid , name); 255 name = url_encode(encodeURI(act)); 256 group = url_encode(encodeURI(group)); 257 }else{ 258 var act = prompt("Digite um novo grupo para : " + name, group); 259 group = url_encode(encodeURI(act)); 260 name = url_encode(encodeURI(name)); 261 } 262 if((act != null) && (act != "")){ 263 var handler_update_contacts = function(data){ 264 if(data) 265 IM.UpdateContacts(); 266 else 267 alert("erro"); 268 } 269 cIM.cExecute("$this.Ujabber.UpdateUser",handler_update_contacts,"jid="+jid+"&name="+name+"&group="+group); 270 } 271 } 272 } 273 274 Preferences.prototype.Update_Group = function(pJid) 300 301 IM_Preferences.prototype.Update_Group = function(pJid) 275 302 { 276 303 this.Update_(pJid,false); 277 304 } 278 305 279 Preferences.prototype.Update_NickName = function(pJid)306 IM_Preferences.prototype.Update_NickName = function(pJid) 280 307 { 281 308 this.Update_(pJid,true); … … 285 312 * Vcard 286 313 */ 287 288 Preferences.prototype.vCardLoad = function() 289 { 290 Templates.information_user(); 291 document.getElementById('FN').value = IM.vcard_user['VCARD_FN']; 292 document.getElementById('NICKNAME').value = IM.vcard_user['VCARD_NICKNAME']; 293 document.getElementById('ORGNAME').value = IM.vcard_user['VCARD_ORGNAME']; 294 document.getElementById('ORGUNIT').value = IM.vcard_user['VCARD_ORGUNIT']; 295 document.getElementById('ROLE').value = IM.vcard_user['VCARD_ROLE']; 296 document.getElementById('BDAY').value = IM.vcard_user['VCARD_BDAY']; 297 document.getElementById('DESC').value = IM.vcard_user['VCARD_DESC']; 298 } 299 300 Preferences.prototype.vCardAdd = function() 314 315 IM_Preferences.prototype.vCardInit = function() 301 316 { 302 317 var _this = this; 303 IM.vcard_user['VCARD_FN'] = document.getElementById('FN').value; 304 _this.save_vcard = url_encode(encodeURI(document.getElementById('FN').value)) + ";"; 305 IM.vcard_user['VCARD_NICKNAME'] = document.getElementById('NICKNAME').value; 306 _this.save_vcard += url_encode(encodeURI(document.getElementById('NICKNAME').value)) + ";"; 307 var nickname = document.getElementById('span_nickname').innerHTML; 308 document.getElementById('span_nickname').innerHTML = (IM.vcard_user['VCARD_NICKNAME']) ? "<b> " + IM.vcard_user['VCARD_NICKNAME'].substring(0,30) + "</b>" : nickname; 309 IM.vcard_user['VCARD_ORGNAME'] = document.getElementById('ORGNAME').value; 310 _this.save_vcard += url_encode(encodeURI(document.getElementById('ORGNAME').value)) + ";"; 311 IM.vcard_user['VCARD_ORGUNIT'] = document.getElementById('ORGUNIT').value; 312 _this.save_vcard += url_encode(encodeURI(document.getElementById('ORGUNIT').value)) + ";"; 313 IM.vcard_user['VCARD_ROLE'] = document.getElementById('ROLE').value; 314 _this.save_vcard += url_encode(encodeURI(document.getElementById('ROLE').value)) + ";"; 315 IM.vcard_user['VCARD_BDAY'] = document.getElementById('BDAY').value; 316 _this.save_vcard += url_encode(encodeURI(document.getElementById('BDAY').value)) + ";"; 317 IM.vcard_user['VCARD_DESC'] = document.getElementById('DESC').value; 318 _this.save_vcard += url_encode(encodeURI(document.getElementById('DESC').value)); 319 var message_desc = document.getElementById('span_message').innerHTML; 320 document.getElementById('span_message').innerHTML = (IM.vcard_user['VCARD_DESC']) ? "<b> " + IM.vcard_user['VCARD_DESC'].substring(0,30) + "</b>" : message_desc ; 321 322 var handler_vcardAdd = function(data){ 323 if(!data) 324 alert(data); 318 var handler_getId = function(_XMLdata) 319 { 320 var jid = _XMLdata.getElementsByTagName("retorno").item(0); 321 jid = jid.firstChild.nodeValue; 322 323 _this.jid = jid; 324 325 var NickName = document.getElementById('span_nickname'); 326 var Message = document.getElementById('span_message'); 327 var vcards = _this.vCardLoad(jid); 328 329 NickName.innerHTML = "<b> " + IM.get_lang('your nickname') + "</b>"; 330 Message.innerHTML = "<b> " + IM.get_lang('your message') + "</b>"; 331 332 for(var i in vcards) 333 { 334 var tag_name = vcards[i].substr(0,vcards[i].indexOf('|')); 335 var tag_value = vcards[i].substr((vcards[i].indexOf('|')+1),vcards[i].length); 336 337 if( tag_name === "NICKNAME") 338 NickName.innerHTML = "<b> " + decodeURI(tag_value.substring(0,15)) + "</b>"; 339 340 if( tag_name === "DESC" ) 341 Message.innerHTML = "<b> " + decodeURI(tag_value.substring(0,20)) + "...</b>"; 342 } 343 } 344 XMLTools.request('$this.Ujabber.getJid','GET',handler_getId); 345 346 } 347 348 IM_Preferences.prototype.vCardLoad = function(Jid) 349 { 350 var div_jid = document.getElementById("vcard_" + Jid); 351 var array_el = []; 352 var elements = div_jid.firstChild; 353 while ( elements ) 354 { 355 if(elements.tagName != undefined && elements.tagName.substr(0,1) != "/" ) 356 { 357 array_el[array_el.length] = elements.tagName + "|" + elements.innerHTML; 358 } 359 elements = elements.nextSibling; 360 } 361 return array_el; 362 } 363 364 IM_Preferences.prototype.vCard = function() 365 { 366 if(!this.jid){ 367 alert('Carregando !!'); 368 }else{ 369 370 Templates.information_user(); 371 var vcards = new Array(); 372 vcards = this.vCardLoad(this.jid); 373 374 for(var i in vcards) 375 { 376 var tag_name = vcards[i].substr(0,vcards[i].indexOf('|')); 377 var tag_value = vcards[i].substr((vcards[i].indexOf('|')+1),vcards[i].length); 378 if(tag_name) 379 document.getElementById(tag_name).value = decodeURI(tag_value); 380 } 381 } 382 } 383 384 IM_Preferences.prototype.vCardLoad_Contact = function(pJid) 385 { 386 if(!this.jid){ 387 alert('Carregando !!'); 388 }else{ 389 Templates.information_Contact(); 390 var vcards = new Array(); 391 vcards = this.vCardLoad(pJid); 392 393 for(var i in vcards) 394 { 395 var tag_name = vcards[i].substr(0,vcards[i].indexOf('|')); 396 var tag_value = vcards[i].substr((vcards[i].indexOf('|')+1),vcards[i].length); 397 if(document.getElementById('_lbl_' + tag_name) != null) 398 document.getElementById('_lbl_' + tag_name).innerHTML = tag_value; 399 } 400 } 401 } 402 403 IM_Preferences.prototype.vCardAdd = function() 404 { 405 var el_vcard = new Array('FN','NICKNAME','ROLE','ORGNAME','ORGUNIT','BDAY','DESC'); 406 var vcard = ""; 407 var value = ""; 408 var div_jid = document.getElementById("vcard_" + this.jid); 409 var elements = div_jid.firstChild; 410 411 for(var i in el_vcard) 412 { 413 value = ( document.getElementById(el_vcard[i]).value ) ? document.getElementById(el_vcard[i]).value : ""; 414 if( elements.tagName == el_vcard[i] && value != "") 415 { 416 if( el_vcard[i] === 'NICKNAME' ) 417 document.getElementById('span_nickname').innerHTML = "<b> " + value.substring(0,15) + "</b>"; 418 if( el_vcard[i] === 'DESC' ) 419 document.getElementById('span_message').innerHTML = "<b> " + value.substring(0,20) + "...</b>"; 420 elements.innerHTML = value; 421 } 422 elements = elements.nextSibling; 423 vcard += value + "_vkrd_"; 424 } 425 426 vcard = vcard.substr(0,vcard.length - 6 ); 427 428 var handler_vcard_add = function(XMLdata) 429 { 430 }; 431 XMLTools.request('$this.Ujabber.newVcard','POST',handler_vcard_add,"vcard="+escape(vcard)); 432 alert('Informações Cadastradas / Adicionads !!!'); 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)) 452 var minutes = func.byId('in_time').value; 325 453 else 326 alert("Informações Cadastradas / Atualizadas !"); 327 } 328 cIM.cExecute("$this.Ujabber.newVcard",handler_vcardAdd,"vcard="+_this.save_vcard); 329 } 330 331 Preferences.prototype.vCardLoad_Contact = function(pJid) 332 { 333 Templates.information_Contact(); 334 for(var i=0; i < IM.array_users.length; i++){ 335 if(IM.array_users[i].jid == pJid){ 336 document.getElementById('_lbl_FN').innerHTML = decodeURI(IM.array_users[i].VCARD_FN); 337 document.getElementById('_lbl_Nickname').innerHTML = decodeURI(IM.array_users[i].VCARD_NICKNAME); 338 document.getElementById('_lbl_Orgunit').innerHTML = decodeURI(IM.array_users[i].VCARD_ORGUNIT); 339 document.getElementById('_lbl_Role').innerHTML = decodeURI(IM.array_users[i].VCARD_ROLE); 340 document.getElementById('_lbl_Birthday').innerHTML = decodeURI(IM.array_users[i].VCARD_BDAY); 341 return; 342 } 454 { 455 alert('Informe valores numéricos'); 456 func.byId('in_time').focus(); 457 return false; 458 } 459 } 460 IM.im_time_ = func.byId('in_time').value; 461 preferences += ( func.trim(func.byId('in_time').value )) ? 'in_time:' + func.byId('in_time').value + ";" : 'in_time:0;'; 462 preferences += ( func.byId('rd_nm').checked ) ? 'rd_nm:true;' : 'rd_nm:false;'; 463 preferences += ( func.byId('rd_ch').checked ) ? 'rd_ch:true' : 'rd_ch:false'; 464 IM.userPrefe = preferences; 465 466 var handler_preferences = function(XMLdata) 467 { 468 var data = XMLdata.getElementsByTagName('retorno').item(0); 469 data = eval(data.firstChild.nodeValue); 470 if(data) 471 { 472 IM.Contacts_Offline(); 473 alert('Preferências salvas !'); 474 } 475 }; 476 XMLTools.request('$this.db_im.set_preferences','POST',handler_preferences,'preferences='+preferences); 477 } 478 479 IM_Preferences.prototype.GetYourPreferences = function() 480 { 481 if(!IM.userPrefe) 482 { 483 var handler_getPreferences = function(XMLdata) 484 { 485 var data = XMLdata.getElementsByTagName('retorno').item(0); 486 data = data.firstChild.nodeValue; 487 IM.userPrefe = data; 488 IM.im_time_ = this.LoadPreferences('ch_offline'); 489 } 490 XMLTools.request('$this.db_im.get_preferences','POST',handler_getPreferences); 491 } 492 } 493 494 IM_Preferences.prototype.LoadPreferences = function(pElement) 495 { 496 var preferences_im = IM.userPrefe; 497 498 while( preferences_im !== "") 499 { 500 var values = ""; 501 var value = ""; 502 if(value = preferences_im.substr(0,preferences_im.indexOf(';'))) 503 { 504 values = value + '\n'; 505 preferences_im = preferences_im.replace(value,''); 506 } 507 if(preferences_im.substr(0,1) == ";"){ 508 preferences_im = preferences_im.substr(1,preferences_im.length); 509 }else{ 510 values = preferences_im + '\n'; 511 preferences_im = ''; 512 } 513 514 var ele = values.substr(0,values.indexOf(':')); 515 var val = values.substr((values.indexOf(':')+1),values.length); 516 517 if(ele == pElement) 518 return val; 519 520 if((document.getElementById(ele)!= null) && (document.getElementById(ele).type == 'text')) 521 document.getElementById(ele).value = val; 522 else 523 if(document.getElementById(ele) != null) 524 document.getElementById(ele).checked = eval(val); 343 525 } 344 526 } … … 348 530 */ 349 531 350 Preferences.prototype.Info_Contact = function(pJid)532 IM_Preferences.prototype.Info_Contact = function(pJid) 351 533 { 352 534 var element = "_span_not_" + pJid; 353 var pElement = "teste";354 535 var uid = pJid.substr(0,pJid.indexOf('@')); 355 356 var handler_ldap = function(data){ 357 358 if(data){ 359 var form_details = '<table cellpadding="0" cellspacing="0" style="background-color:#cbdae4;width:80%;border:1px solid #809aa9">' + 360 '<tr><td style="vertical-align:top;width:80%">' + 361 '<div style="padding-bottom">' + 362 '<span><label>'+IM.get_lang('Name')+'</label></br>'+ data[0].cn + '</span></br></br>' + 363 '<span><label>'+IM.get_lang('E-mail')+'</label></br>'+ data[0].mail + '</span></br>' + 364 '</div></td>' + 365 '<td style="vertical-align:top"><img id="' + pJid + '_avatar" src="' + img_photo.src + '" style="height:65px;width:60px;align:right">' + 366 '</td></tr>'+ 367 '</table>'; 368 369 im_menu_action.menu(element, form_details); 370 536 var handler_ldap = function(data) 537 { 538 var data = func.interface(data); 539 var XMLinfoLdap = ""; 540 if(data) 541 { 542 XMLinfoLdap = '<info_user>'; 543 for(var i in data) 544 XMLinfoLdap += '<item lang_name="'+IM.get_lang('Name')+'" name="'+ data[i].cn +'" lang_email="'+IM.get_lang('E-mail')+'" email="'+ data[i].mail +'" />'; 545 XMLinfoLdap += '</info_user>'; 546 } 547 im_menu_action.menu(element, parse_XmlXsl(XMLinfoLdap,'info_contact_ldap.xsl')); 548 if(document.getElementById('im_span_avatar') != null) 549 { 550 var span = document.getElementById('im_span_avatar'); 551 var img = func.newEl('img'); 552 func.confEl(img, 'id', pJid + '_avatar'); 553 func.confEl(img, 'src', img_photo.src); 554 func.confEl(img, 'style', 'height:65px;width:60px;align:right;'); 555 span.appendChild(img); 371 556 // Foto Ldap; 372 557 im_win.get_photo_ldap(pJid); 373 558 } 374 559 } 375 cIM.cExecute("$this.ldap_im.info_user",handler_ldap,"uid="+uid); 376 377 560 XMLTools.request('$this.ldap_im.info_user','POST',handler_ldap,'uid='+uid); 378 561 } 379 562 … … 382 565 */ 383 566 384 Preferences.prototype.SendFile = function(pJid)567 IM_Preferences.prototype.SendFile = function(pJid) 385 568 { 386 569 if(im_send_file == 'true'){ 387 570 Templates.Send_file(pJid); 388 571 }else{ 389 alert('Funç ão Indisponível!');572 alert('Funçao Indisponível!'); 390 573 } 391 574 } 392 575 393 Preferences.prototype.SizeFile = function()576 IM_Preferences.prototype.SizeFile = function() 394 577 { 395 var h_SizeFile = function(data){ 578 var h_SizeFile = function(data) 579 { 396 580 alert(data); 397 581 } 398 582 cIM.cExecute("$this.upload.size_file",h_SizeFile); 399 583 } 400 401 /*402 * Preferências do Usuário403 */404 405 Preferences.prototype.yourPreferences = function()406 {407 Templates.yourPreferences();408 if( IM.array_prefe['sizeof'] > 0 ){409 document.getElementById('ch_time').checked = eval(IM.array_prefe['ch_time']);410 document.getElementById('ch_offline').checked = eval(IM.array_prefe['ch_offline']);411 document.getElementById('ch_contacts').checked = eval(IM.array_prefe['ch_contacts']);412 document.getElementById('rd_nm').checked = eval(IM.array_prefe['rd_nm']);413 document.getElementById('rd_al').checked = eval(IM.array_prefe['rd_al']);414 document.getElementById('rd_ch').checked = eval(IM.array_prefe['rd_ch']);415 }else{416 this.GetPreferences();417 }418 419 }420 421 Preferences.prototype.SetPreferences = function()422 {423 var EcheckBox = new Array();424 EcheckBox[0] = 'ch_time';425 EcheckBox[1] = 'ch_offline';426 EcheckBox[2] = 'ch_contacts';427 var Eradio = new Array()428 Eradio[0] = 'rd_nm';429 Eradio[1] = 'rd_al';430 Eradio[2] = 'rd_ch';431 var preferences = '';432 var _this = this;433 434 for(var i in EcheckBox){435 if(document.getElementById(EcheckBox[i]).checked){436 preferences += EcheckBox[i] + ':' + true + ';';437 IM.array_prefe[EcheckBox[i]] = true;438 }else{439 preferences += EcheckBox[i] + ':' + false + ';';440 IM.array_prefe[EcheckBox[i]] = false;441 }442 IM.array_prefe['sizeof'] = i;443 }444 445 for(var i in Eradio){446 if(document.getElementById(Eradio[i]).checked){447 preferences += Eradio[i] + ':' + true + ';';448 IM.array_prefe[Eradio[i]] = true;449 }else{450 preferences += Eradio[i] + ':' + false + ';';451 IM.array_prefe[Eradio[i]] = false;452 }453 IM.array_prefe['sizeof'] = IM.array_prefe['sizeof'] = i + 1;454 }455 456 var handler_set_preferences = function(data)457 {458 if(data)459 alert('Preferências cadastradas com sucesso!');460 IM.ContactsOffline();461 }462 cIM.cExecute("$this.db_im.set_preferences",handler_set_preferences,"preferences="+preferences);463 464 }465 466 Preferences.prototype.GetPreferences = function()467 {468 var handler_get_preferences = function(data){469 var opt = data.split(";");470 for(var i in opt){471 if(opt[i] != ""){472 var el = opt[i].split(":");473 if(document.getElementById(el[0]) != null){474 var id_el = document.getElementById(el[0]);475 id_el.checked = eval(el[1]);476 }477 IM.array_prefe[el[0]] = eval(el[1]);478 IM.array_prefe['sizeof'] = i;479 }480 }481 }482 cIM.cExecute("$this.db_im.get_preferences",handler_get_preferences);483 484 }485 486 /*487 * Tela de permissão para novos contatos488 */489 490 Preferences.prototype.Refresh_Screen = function(pJid)491 {492 var el_tbl = document.getElementById("_cell_" + pJid);493 if(el_tbl != null)494 el_tbl.parentNode.removeChild(el_tbl);495 }496 584 497 // Build Object 498 var Preferences = new Preferences(); 585 // Build Object 586 587 var IM_Preferences = new IM_Preferences();
Note: See TracChangeset
for help on using the changeset viewer.