Changeset 3086 for trunk/jabberit_messenger/jmessenger/js/trophyim.js
- Timestamp:
- 07/23/10 18:00:12 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/jabberit_messenger/jmessenger/js/trophyim.js
r3082 r3086 629 629 return true; 630 630 }, 631 631 632 /** Function: onPresence 632 633 * 633 634 * Presence handler 634 635 */ 636 635 637 onPresence : function(msg) 636 638 { 639 // Get Presence ChatRoom 640 TrophyIM.onPresenceChatRoom(msg); 641 637 642 var type = msg.getAttribute('type') ? msg.getAttribute('type') : 'available'; 638 643 var show = msg.getElementsByTagName('show').length ? Strophe.getText(msg.getElementsByTagName('show')[0]) : type; … … 644 649 return true; 645 650 }, 651 652 /** Function : onPresenceChatRoom 653 * 654 * 655 */ 656 657 onPresenceChatRoom : function(msg) 658 { 659 var xquery = msg.getElementsByTagName("x"); 660 661 if ( xquery.length > 0 ) 662 { 663 for ( var i = 0; i < xquery.length; i++ ) 664 { 665 var xmlns = xquery[i].getAttribute("xmlns"); 666 667 if( xmlns.indexOf("http://jabber.org/protocol/muc#user") == 0 ) 668 { 669 var nameChatRoom = xquery[i].parentNode.getAttribute('from') 670 nameChatRoom = Strophe.getBareJidFromJid(nameChatRoom); 671 672 var nickName = xquery[i].firstChild.getAttribute('jid'); 673 nickName = Strophe.getBareJidFromJid( nickName ); 674 nickName = nickName.substring(0, nickName.indexOf('@')); 675 676 var type = xquery[i].parentNode.getAttribute('type') ? xquery[i].parentNode.getAttribute('type') : 'available' ; 677 678 var show = ( xquery[i].parentNode.firstChild.firstChild != null ) ? xquery[i].parentNode.firstChild.firstChild.nodeValue : type ; 679 680 if ( Strophe.getBareJidFromJid( xquery[i].firstChild.getAttribute('jid') ) == Strophe.getBareJidFromJid( TrophyIM.connection.jid ) ) 681 show = loadscript.getStatusUserIM(); 682 683 var _UserChatRoom = document.createElement("div"); 684 _UserChatRoom.id = nameChatRoom + "_UserChatRoom__" + xquery[i].firstChild.getAttribute('jid'); 685 _UserChatRoom.setAttribute("style","padding-left:18px ; margin:3px 0px 0px 2px; background: url('"+path_jabberit+"templates/default/images/" + show + ".gif')no-repeat center left"); 686 _UserChatRoom.appendChild( document.createTextNode(nickName) ); 687 688 var nodeUser = document.getElementById( nameChatRoom + "_UserChatRoom__" + xquery[i].firstChild.getAttribute('jid')); 689 690 if( nodeUser == null ) 691 { 692 nameChatRoom = document.getElementById(nameChatRoom + '__roomChat__participants'); 693 nameChatRoom.appendChild( _UserChatRoom ); 694 } 695 else 696 { 697 if( type == 'unavailable' ) 698 { 699 nodeUser.parentNode.removeChild( nodeUser ); 700 } 701 else if( show ) 702 { 703 var _UserChatRoom = document.getElementById( nameChatRoom + "_UserChatRoom__" + xquery[i].firstChild.getAttribute('jid') ) 704 705 _UserChatRoom.setAttribute("style","padding-left:18px ; margin:3px 0px 0px 2px; background: url('"+path_jabberit+"templates/default/images/" + show + ".gif')no-repeat center left"); 706 } 707 } 708 } 709 } 710 } 711 }, 646 712 647 713 /** Function: onMessage … … 649 715 * Message handler 650 716 */ 717 651 718 onMessage : function(msg) 652 719 {
Note: See TracChangeset
for help on using the changeset viewer.