Changeset 64 for trunk/instant_messenger/js/im_functions.js
- Timestamp:
- 09/05/07 11:18:58 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/instant_messenger/js/im_functions.js
r63 r64 9 9 this.im_time_ = false; 10 10 } 11 11 12 12 IM.prototype.load_im = function() 13 13 { 14 14 IM.listen(); 15 15 IM.requireContacts(); 16 16 17 17 var handler_Status = function(XmlData) 18 18 { … … 27 27 XMLTools.request('$this.Ujabber.MyPresence', 'GET', handler_Status); 28 28 }; 29 29 30 30 IM.prototype.listen = function() 31 31 { 32 32 if ( !this._listen ) 33 33 return false; 34 34 35 35 var _this = this; 36 36 var handler = function(data) … … 43 43 IM_Preferences.GetYourPreferences(); 44 44 } 45 45 46 46 _this.getContacts(data); 47 47 _this.getPresence(data); … … 49 49 _this.getMessages(data); 50 50 _this.getVcard(data); 51 51 52 52 if(!_this.vcards) 53 53 { … … 68 68 }; 69 69 70 /* 70 /* 71 71 * Contacts 72 72 */ 73 73 74 74 IM.prototype.requireContacts = function() 75 75 { … … 99 99 var a = document.createElement('div'); 100 100 a.innerHTML = XMLTools.transform(node, xsl); 101 101 102 102 div.innerHTML = ''; 103 103 div.appendChild(img); 104 104 div.appendChild(document.createTextNode(this.get_lang('List of Contacts'))); 105 105 div.appendChild(a); 106 106 107 107 var group = func.byId("all_groups").firstChild; 108 108 while ( group ) … … 123 123 img.id = "img_" + group.id; 124 124 var el_parent = group; 125 125 126 126 el_parent.insertBefore(img,el_parent.firstChild); 127 127 128 128 } catch(e){} 129 129 group = group.nextSibling; … … 136 136 //alert('getContacts()' + e); 137 137 } 138 139 }; 140 141 /* 138 139 }; 140 141 /* 142 142 * Visible / Unvisible 143 143 */ … … 152 152 img.src = img_group_close.src; 153 153 } 154 154 155 155 IM.prototype.unvisible_group = function(el) 156 156 { … … 162 162 img.src = img_group_open.src; 163 163 } 164 164 165 165 /* 166 166 * Presence 167 167 */ 168 168 169 169 IM.prototype.getPresence = function(data) 170 170 { … … 187 187 else 188 188 var status_message = false; 189 190 191 189 192 190 if( from ) … … 203 201 } 204 202 break; 205 206 203 case 'subscribed' : 207 204 // 208 205 break; 209 210 case 'unsubscribe' : 206 case 'unsubscribe' : 211 207 Subscription.unsubscribe(from); 212 208 type = 'unavailable'; 213 209 func.byId(from).firstChild.src = eval('img_' + type + '.src'); 214 210 break; 215 case 'unsubscribed' : 211 case 'unsubscribed' : 216 212 Subscription.unsubscribed(from); 217 213 type = 'unavailable'; … … 232 228 else 233 229 status.innerHTML = ''; 234 235 230 } 236 231 … … 244 239 if( status_message != "available" ) 245 240 lbl.innerHTML = "<span style='margin-left:10px'><br/> ( " + status_message + " )</span>"; 246 func.byId(from).appendChild(lbl); 241 func.byId(from).appendChild(lbl); 247 242 }else{ 248 243 var lbl = document.getElementById('status_message_' + from); … … 266 261 } 267 262 }; 268 263 269 264 /* 270 265 * Contatos - Offline 271 266 */ 272 267 273 268 IM.prototype.Contacts_Offline = function() 274 269 { … … 296 291 } 297 292 } 298 293 299 294 /* 300 295 * Get / Send - Messages 301 296 */ 302 297 303 298 IM.prototype.getMessages = function(data) 304 299 { … … 325 320 nickname = func.trim(nickname); 326 321 } 327 322 328 323 var win = document.getElementById(from + '_chatMessages'); 329 324 if ( !win ) … … 332 327 win = document.getElementById(from + '_chatMessages'); 333 328 } 334 329 335 330 var el = message.firstChild; 336 331 while ( el ) … … 338 333 var xsl = XMLTools.load(im_path + 'xsl/message.xsl?' + Date.parse(new Date)); 339 334 var next = el.nextSibling; 340 335 341 336 var label = document.createElement('strong'); 342 337 if(nickname) 343 338 label.appendChild(document.createTextNode(nickname)); 344 339 else 345 label.appendChild(document.createTextNode(from)); 340 label.appendChild(document.createTextNode(from)); 346 341 win.appendChild(label); 347 342 win.appendChild(document.createElement('br')); … … 352 347 win.scrollTop = win.scrollHeight; 353 348 im_win.newMessageNotification(); 354 349 355 350 el = next; 356 351 } … … 370 365 } 371 366 } 372 367 373 368 IM.prototype.sendMessage = function (pJID) 374 369 { … … 391 386 392 387 envio.innerHTML = ''; 393 388 394 389 var message_element = document.getElementById(pJID + '_chatMessages'); 395 390 var nickname = "me "; … … 401 396 nickname = nickname.substr(nickname.indexOf(':') + 1 , nickname.length); 402 397 } 403 398 404 399 message_element.innerHTML += '<strong>' + nickname + ' '; 405 400 message_element.innerHTML += ' ' + _this.get_lang('speak') + ':</strong><br/>'; 406 401 message_element.innerHTML += message_text + '<br/>'; 407 402 message_element.scrollTop = message_element.scrollHeight; 408 403 409 404 var handler_sendMessage = function(data) 410 405 { … … 416 411 } 417 412 }; 418 413 419 414 IM.prototype.getComposing = function(data) 420 415 { … … 429 424 if ( composing.style.display = 'none' ) 430 425 composing.style.display = 'block'; 431 426 432 427 if ( node.nodeName == 'paused' ) 433 428 if ( (composing = func.byId(node.getAttribute('from') + '_composing')) ) … … 439 434 } 440 435 }; 441 436 442 437 /* 443 438 * Get_lang 444 439 */ 445 440 446 441 IM.prototype.get_lang = function(_key, _arg1, _arg2, _arg3, _arg4) 447 442 { 448 443 var _value = ""; 449 444 450 445 if ( !lang_im[_key.toLowerCase()] ) 451 446 return _key + "*"; 452 447 453 448 _value = lang_im[_key.toLowerCase()]; 454 449 455 450 if ( _arg1 || _arg2 ||_arg3 || _arg4 ) 456 451 { … … 462 457 } 463 458 } 464 459 465 460 return _value; 466 461 }; 467 462 468 463 IM.prototype.getWinContactsState = function() 469 464 { … … 474 469 win_state = ( win_state ) ? win_state : ( windowItems['contacts'].state == WINDOW_STATE_MAXIMIZED ) ? true : false; 475 470 return win_state; 476 471 477 472 }catch(e){} 478 473 }; 479 474 480 475 IM.prototype.showContacts = function() 481 476 { … … 488 483 } 489 484 }; 490 485 491 486 /* 492 487 * Smiles … … 503 498 return pEmotion; 504 499 } 505 500 506 501 IM.prototype.atalho = function() 507 502 { … … 548 543 * Vcard 549 544 */ 550 545 551 546 IM.prototype.requireVcard = function() 552 547 { … … 561 556 XMLTools.request('$this.Ujabber.requireVcard','GET',handler_getVcard); 562 557 } 563 558 564 559 IM.prototype.getVcard = function(data) 565 560 { 566 561 var _this = this; 567 562 try 568 { 563 { 569 564 if ( data.getElementsByTagName('vcard').length > 0 && !_this.statusvcard ) 570 565 { … … 572 567 var xsl = XMLTools.load(im_path + 'xsl/vcard_contacts.xsl?' + Date.parse(new Date)); 573 568 _this.statusvcard = true; 574 569 575 570 div.innerHTML = ""; 576 571 div.innerHTML += XMLTools.transform(data, xsl); … … 580 575 }catch(e){} 581 576 582 583 }; 584 577 578 }; 579 585 580 IM.prototype.open_chat = function(pJID) 586 581 { 587 582 im_win.open_chat(pJID); 588 583 }; 589 584 590 585 IM.prototype.action_button = function(pEv, pJid) 591 586 { … … 618 613 } 619 614 }; 620 615 621 616 IM.prototype.menu_button_right = function(pElement, pX, pY) 622 617 { … … 637 632 /* 638 633 * Menu 639 */ 634 */ 640 635 641 636 IM.prototype.menu_preferences = function() … … 644 639 var posy = 0; 645 640 var pEv = arguments[0]; 646 641 647 642 if (pEv.pageX || pEv.pageY) 648 643 { … … 655 650 posy = pEv.clientY + document.body.scrollTop + document.documentElement.scrollTop; 656 651 } 657 652 658 653 var p_element = document.getElementById(arguments[1]); 659 var _xmlDoc = ""; 654 var _xmlDoc = ""; 660 655 var _this = this; 661 656 662 _xmlDoc = '<menu>' + 663 '<item function="IM_Preferences.Add_userLoad()" lang="'+IM.get_lang('Add Contact')+'"/>' + 657 _xmlDoc = '<menu>' + 658 '<item function="IM_Preferences.Add_userLoad()" lang="'+IM.get_lang('Add Contact')+'"/>' + 664 659 '<item function="IM_Preferences.Remove_userLoad()" lang="'+IM.get_lang('Remove Contact')+'"/>' + 665 660 '<item function="IM_Preferences.vCard()" lang="'+IM.get_lang('Information')+'"/>' + 666 661 '<item function="IM_Preferences.yourPreferences()" lang="'+IM.get_lang('preferences')+'"/>' + 667 662 '</menu>'; 668 663 669 664 im_menu_action.menu(p_element.id,parse_XmlXsl(_xmlDoc,'menu_preferences.xsl')); 670 665 func.byId(p_element).style.top = posy; … … 674 669 _this.Load_Images_menu(); 675 670 } 676 671 677 672 IM.prototype.Load_Images_menu = function(Element) 678 673 { … … 681 676 var group = document.getElementById("dl_im_menu_preferences"); 682 677 var Child = group.childNodes; 683 678 684 679 for(var i = 0; i < Child.length; i++) 685 680 { … … 689 684 } 690 685 }catch (e){} 691 692 686 } 693 687 694 688 /* 695 689 * Função Provisória - By AlC … … 698 692 function parse_XmlXsl(_xmlDoc, form_xsl) 699 693 { 700 var xslWin = false; 701 694 var xslWin = false; 695 702 696 if ( !xslWin ) xslWin = XMLTools.load(im_path + 'xsl/' + form_xsl + '?' + Date.parse(new Date)); 703 697 704 698 a = document.createElement('div'); 705 699 if (window.ActiveXObject) … … 715 709 } 716 710 a.innerHTML = XMLTools.transform(xmlDoc, xslWin); 717 711 718 712 return a; 719 713 720 714 } 721 715 … … 724 718 var _dt = func.newEl('dt', 'dt', 'dt', 'dt', 'dt'); 725 719 var _a = func.newEl('a', 'a', 'a', 'a', 'a'); 726 720 727 721 for ( var i in _dt ) 728 722 { … … 732 726 eval('var option' + (parseInt(i)+1) + '_link = _a[' + i + '];'); 733 727 } 734 728 735 729 var _img = func.newEl('img', 'img', 'img', 'img','img'); 736 730 737 731 for ( var i in _img ) 738 732 { … … 741 735 eval('var option' + (parseInt(i)+1) + '_image = _img[' + i + '];'); 742 736 } 743 737 744 738 option1_link.onclick = function(){statusFlag = 'available'; IM.setStatus('available');}; 745 739 option2_link.onclick = function(){statusFlag = 'xa'; IM.setStatus('xa');}; … … 747 741 option4_link.onclick = function(){statusFlag = 'unavailable'; IM.setStatus('unavailable');}; 748 742 option5_link.onclick = function(){IM.setStatus('custom')}; 749 743 750 744 func.confEl(option1_image, 'src', img_available.src); 751 745 func.confEl(option1_image, 'style', 'width:16px;height:16px;cursor:pointer;'); … … 758 752 func.confEl(option5_image, 'src', img_edit.src); 759 753 func.confEl(option5_image, 'style', 'width:16px;height:16px;cursor:pointer;'); 760 754 761 755 func.insEl(option1_image, IM.get_lang('online'), option1_link); 762 756 func.confEl(option1_link, 'style','cursor:pointer;'); … … 778 772 func.confEl(option5_link, 'style','cursor:pointer;'); 779 773 func.insEl(option5_link, option5); 780 774 781 775 im_menu_action.menu('fast_menu_im', option1, option2, option3, option4, option5); 782 776 }; … … 817 811 catch(e){} 818 812 }; 819 813 820 814 IM.prototype.ImgStatus = function(pStatus) 821 815 { … … 841 835 } 842 836 }; 843 837 844 838 IM.prototype.infoContact = function(pUid) 845 839 {
Note: See TracChangeset
for help on using the changeset viewer.