Changeset 3126 for trunk/jabberit_messenger/jmessenger/js/trophyim.js
- Timestamp:
- 08/03/10 14:27:44 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/jabberit_messenger/jmessenger/js/trophyim.js
r3099 r3126 142 142 autoConnection : { connect : true }, 143 143 144 /** Active Chat Room 145 * 146 */ 147 148 activeChatRoom : { name : [] }, 149 144 150 /** Object: chatHistory 145 151 * … … 663 669 { 664 670 var xquery = msg.getElementsByTagName("x"); 665 671 666 672 if ( xquery.length > 0 ) 667 673 { … … 672 678 if( xmlns.indexOf("http://jabber.org/protocol/muc#user") == 0 ) 673 679 { 674 var nameChatRoom= xquery[i].parentNode.getAttribute('from');675 nameChatRoom = Strophe.getBareJidFromJid(nameChatRoom);676 677 var nickName = xquery[i].parentNode.getAttribute('from');678 nickName = Strophe.getResourceFromJid(nickName);680 var _from = xquery[i].parentNode.getAttribute('from'); 681 var _to = xquery[i].parentNode.getAttribute('to'); 682 683 // Get NameChatRoom 684 var nameChatRoom = Strophe.getBareJidFromJid( _from ); 679 685 680 var type = xquery[i].parentNode.getAttribute('type') ? xquery[i].parentNode.getAttribute('type') : 'available' ; 686 // Get nickName 687 var nickName = Strophe.getResourceFromJid( _from ); 681 688 682 var show = ( xquery[i].parentNode.firstChild.firstChild != null ) ? xquery[i].parentNode.firstChild.firstChild.nodeValue : type ; 689 // Get Type/Show 690 var type = ( xquery[i].parentNode.getAttribute('type') != null ) ? xquery[i].parentNode.getAttribute('type') : 'available' ; 691 var show = ( xquery[i].parentNode.firstChild.nodeName == "show" ) ? xquery[i].parentNode.firstChild.firstChild.nodeValue : type; 683 692 684 if( xquery[i].firstChild.getAttribute('jid') ) 685 { 686 if ( Strophe.getBareJidFromJid( xquery[i].firstChild.getAttribute('jid') ) == Strophe.getBareJidFromJid( TrophyIM.connection.jid ) ) 687 show = loadscript.getStatusUserIM(); 688 } 689 690 var _UserChatRoom = document.createElement("div"); 691 _UserChatRoom.id = nameChatRoom + "_UserChatRoom__" + xquery[i].firstChild.getAttribute('jid'); 692 _UserChatRoom.setAttribute("style","padding-left:18px ; margin:3px 0px 0px 2px; background: url('"+path_jabberit+"templates/default/images/" + show + ".gif')no-repeat center left"); 693 _UserChatRoom.appendChild( document.createTextNode(nickName) ); 694 695 var nodeUser = document.getElementById(nameChatRoom + "_UserChatRoom__" + xquery[i].firstChild.getAttribute('jid') ); 696 697 if( nodeUser == null && xquery[i].firstChild.getAttribute('jid') ) 693 var _idElement = nameChatRoom + "_UserChatRoom__" + nickName; 694 695 var _UserChatRoom = document.createElement("div"); 696 _UserChatRoom.id = _idElement; 697 _UserChatRoom.setAttribute("style","padding-left:18px ; margin:3px 0px 0px 2px; background: url('"+path_jabberit+"templates/default/images/" + show + ".gif')no-repeat center left"); 698 _UserChatRoom.appendChild( document.createTextNode( nickName ) ); 699 700 var nodeUser = document.getElementById( _idElement ); 701 702 if( nodeUser == null ) 698 703 { 699 704 if( document.getElementById( nameChatRoom + '__roomChat__participants' ) != null ) … … 704 709 else 705 710 { 706 TrophyIM.makeChatRoom( nameChatRoom, nameChatRoom 711 TrophyIM.makeChatRoom( nameChatRoom, nameChatRoom.substring(0, nameChatRoom.indexOf('@'))); 707 712 nameChatRoom = document.getElementById( nameChatRoom + '__roomChat__participants' ); 708 713 nameChatRoom.appendChild( _UserChatRoom ); … … 713 718 if( type == 'unavailable' ) 714 719 { 715 var nodeUser = "";716 717 if( xquery[i].firstChild.getAttribute('jid') != null )718 nodeUser = document.getElementById( nameChatRoom + "_UserChatRoom__" + xquery[i].firstChild.getAttribute('jid') );719 else720 nodeUser = document.getElementById( nameChatRoom + "_UserChatRoom__" + xquery[i].parentNode.getAttribute('to') );721 722 720 nodeUser.parentNode.removeChild( nodeUser ); 723 721 } 724 722 else if( show ) 725 723 { 726 var _UserChatRoom = document.getElementById( nameChatRoom + "_UserChatRoom__" + xquery[i].firstChild.getAttribute('jid') ) 727 _UserChatRoom.setAttribute("style","padding-left:18px ; margin:3px 0px 0px 2px; background: url('"+path_jabberit+"templates/default/images/" + show + ".gif')no-repeat center left"); 724 nodeUser.setAttribute("style","padding-left:18px ; margin:3px 0px 0px 2px; background: url('"+path_jabberit+"templates/default/images/" + show + ".gif')no-repeat center left"); 728 725 } 729 726 } … … 1102 1099 { 1103 1100 TrophyIM.leaveChatRoom( jidChatRoom ); 1101 1102 if( TrophyIM.activeChatRoom.name.length > 0 ) 1103 { 1104 for( var i = 0; i < TrophyIM.activeChatRoom.name.length ; i++ ) 1105 { 1106 if( TrophyIM.activeChatRoom.name[i].indexOf( jidChatRoom ) >= 0 ) 1107 { 1108 TrophyIM.activeChatRoom.name[i] = ""; 1109 } 1110 } 1111 } 1104 1112 1105 1113 setTimeout( function() … … 1275 1283 joinChatRoom : function( roomName ) 1276 1284 { 1277 var presence = $pres( {from: TrophyIM.connection.jid, to: roomName}).c("x",{xmlns: Strophe.NS.MUC});1285 var presence = $pres( {from: TrophyIM.connection.jid, to: roomName} ).c("x",{xmlns: Strophe.NS.MUC}); 1278 1286 1279 1287 TrophyIM.connection.send( presence ); … … 1303 1311 getListRooms : function() 1304 1312 { 1305 var _error_return = function(element)1313 if( TrophyIM.statusConn.connected ) 1306 1314 { 1307 alert( " ERROR : " + element ); 1308 }; 1309 1310 var iq = $iq({to: "conference.im.pr.gov.br", type: "get"}).c("query",{xmlns: Strophe.NS.DISCO_ITEMS}); 1311 1312 TrophyIM.connection.sendIQ( iq, loadscript.listRooms, _error_return, 500 ); 1315 var _error_return = function(element) 1316 { 1317 alert("ERRO : Tente novamente !"); 1318 }; 1319 1320 var iq = $iq({ to: TROPHYIM_CHATROOM, type: "get" }).c("query",{xmlns: Strophe.NS.DISCO_ITEMS }); 1321 1322 TrophyIM.connection.sendIQ( iq, loadscript.listRooms, _error_return, 500 ); 1323 }else 1324 alert( "ERRO : Sem conexão com o servidor " + TROPHYIM_CHATROOM ); 1325 1313 1326 }, 1314 1327 … … 1748 1761 TrophyIM.connection.send($pres( ).attrs({ from: jidFrom, to: jidTo, type: _typeSubscription, id: _id }).tree()); 1749 1762 }, 1750 1763 1751 1764 /** Function: setPresence 1752 1765 * … … 1755 1768 setPresence : function( _type ) 1756 1769 { 1770 var presence_chatRoom = ""; 1771 1757 1772 if( _type != 'status') 1758 1773 { … … 1804 1819 1805 1820 TrophyIM.connection.send( _presence.tree() ); 1821 1822 presence_chatRoom = _type; 1806 1823 } 1807 1824 else 1808 1825 { 1809 1826 TrophyIM.connection.send($pres( ).c('show').t(_type).tree()); 1827 1828 presence_chatRoom = _type; 1810 1829 } 1811 1830 } … … 1851 1870 1852 1871 TrophyIM.connection.send( _presence.tree() ); 1853 } 1854 } 1872 1873 presence_chatRoom = _show; 1874 } 1875 } 1876 1877 // Send Presence Chat Room 1878 if( TrophyIM.activeChatRoom.name.length > 0 ) 1879 { 1880 for( var i in TrophyIM.activeChatRoom.name ) 1881 { 1882 if( TrophyIM.activeChatRoom.name[i] != "" ) 1883 TrophyIM.connection.send($pres( { to : TrophyIM.activeChatRoom.name[i] } ).c('show').t( presence_chatRoom ) ); 1884 } 1885 } 1886 1855 1887 }, 1856 1888
Note: See TracChangeset
for help on using the changeset viewer.