Ignore:
Timestamp:
08/03/10 14:54:57 (14 years ago)
Author:
alexandrecorreia
Message:

Ticket #1091 - Implementado a busca de salas para bate-papo no novo modulo Expresso messenger XEP-0045-MUC.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/jabberit_messenger/jmessenger/js/trophyim.mini.js

    r3102 r3127  
    11 
    2 var TROPHYIM_BOSH_SERVICE="/proxy/ejabberd";var TROPHYIM_LOG_LINES=200;var TROPHYIM_LOGLEVEL=0;var TROPHYIM_VERSION="0.3";var TROPHYIM_RESOURCE="/JABBERITWEB";var TROPHYIM_CHATROOM="conference.im.pr.gov.br";DOMObjects={xmlParse:function(xmlString){var xmlObj=this.xmlRender(xmlString);if(xmlObj){try{if(this.processor==undefined){this.processor=new XSLTProcessor();this.processor.importStylesheet(this.xmlRender('<xsl:stylesheet version="1.0"\ 
     2DOMObjects={xmlParse:function(xmlString){var xmlObj=this.xmlRender(xmlString);if(xmlObj){try{if(this.processor==undefined){this.processor=new XSLTProcessor();this.processor.importStylesheet(this.xmlRender('<xsl:stylesheet version="1.0"\ 
    33                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\ 
    44                    <xsl:output method="html" indent="yes"/><xsl:template\ 
     
    1313return renderObj;},getHTML:function(page) 
    1414{return this.xmlParse(HTMLSnippets[page]);},getScript:function(script) 
    15 {var newscript=document.createElement('script');newscript.setAttribute('src',script);newscript.setAttribute('type','text/javascript');return newscript;}};TrophyIM={controll:{notificationNewUsers:0},autoConnection:{connect:true},chatHistory:{},constants:{stale_roster:false},posWindow:{left:400,top:100},statusConn:{connected:false},_timeOut:{renderRoster:null},setCookie:function(name,value) 
     15{var newscript=document.createElement('script');newscript.setAttribute('src',script);newscript.setAttribute('type','text/javascript');return newscript;}};TrophyIM={controll:{notificationNewUsers:0},autoConnection:{connect:true},activeChatRoom:{name:[]},chatHistory:{},constants:{stale_roster:false},posWindow:{left:400,top:100},statusConn:{connected:false},_timeOut:{renderRoster:null},setCookie:function(name,value) 
    1616{var expire=new Date();expire.setDate(expire.getDate()+365);document.cookie=name+"="+value+"; expires="+expire.toGMTString();},delCookie:function(name) 
    1717{var expire=new Date();expire.setDate(expire.getDate()-365);document.cookie=name+"= ; expires="+expire.toGMTString();delete TrophyIM.cookies[name];},getCookies:function() 
     
    104104{for(var i=0;i<xquery.length;i++) 
    105105{var xmlns=xquery[i].getAttribute("xmlns");if(xmlns.indexOf("http://jabber.org/protocol/muc#user")==0) 
    106 {var nameChatRoom=xquery[i].parentNode.getAttribute('from');nameChatRoom=Strophe.getBareJidFromJid(nameChatRoom);var nickName=xquery[i].parentNode.getAttribute('from');nickName=Strophe.getResourceFromJid(nickName);var type=xquery[i].parentNode.getAttribute('type')?xquery[i].parentNode.getAttribute('type'):'available';var show=(xquery[i].parentNode.firstChild.firstChild!=null)?xquery[i].parentNode.firstChild.firstChild.nodeValue:type;if(xquery[i].firstChild.getAttribute('jid')) 
    107 {if(Strophe.getBareJidFromJid(xquery[i].firstChild.getAttribute('jid'))==Strophe.getBareJidFromJid(TrophyIM.connection.jid)) 
    108 show=loadscript.getStatusUserIM();} 
    109 var _UserChatRoom=document.createElement("div");_UserChatRoom.id=nameChatRoom+"_UserChatRoom__"+xquery[i].firstChild.getAttribute('jid');_UserChatRoom.setAttribute("style","padding-left:18px ; margin:3px 0px 0px 2px; background: url('"+path_jabberit+"templates/default/images/"+show+".gif')no-repeat center left");_UserChatRoom.appendChild(document.createTextNode(nickName));var nodeUser=document.getElementById(nameChatRoom+"_UserChatRoom__"+xquery[i].firstChild.getAttribute('jid'));if(nodeUser==null&&xquery[i].firstChild.getAttribute('jid')) 
     106{var _from=xquery[i].parentNode.getAttribute('from');var _to=xquery[i].parentNode.getAttribute('to');var nameChatRoom=Strophe.getBareJidFromJid(_from);var nickName=Strophe.getResourceFromJid(_from);var type=(xquery[i].parentNode.getAttribute('type')!=null)?xquery[i].parentNode.getAttribute('type'):'available';var show=(xquery[i].parentNode.firstChild.nodeName=="show")?xquery[i].parentNode.firstChild.firstChild.nodeValue:type;var _idElement=nameChatRoom+"_UserChatRoom__"+nickName;var _UserChatRoom=document.createElement("div");_UserChatRoom.id=_idElement;_UserChatRoom.setAttribute("style","padding-left:18px ; margin:3px 0px 0px 2px; background: url('"+path_jabberit+"templates/default/images/"+show+".gif')no-repeat center left");_UserChatRoom.appendChild(document.createTextNode(nickName));var nodeUser=document.getElementById(_idElement);if(nodeUser==null) 
    110107{if(document.getElementById(nameChatRoom+'__roomChat__participants')!=null) 
    111108{nameChatRoom=document.getElementById(nameChatRoom+'__roomChat__participants');nameChatRoom.appendChild(_UserChatRoom);} 
    112109else 
    113 {TrophyIM.makeChatRoom(nameChatRoom,nameChatRoom);nameChatRoom=document.getElementById(nameChatRoom+'__roomChat__participants');nameChatRoom.appendChild(_UserChatRoom);}} 
     110{TrophyIM.makeChatRoom(nameChatRoom,nameChatRoom.substring(0,nameChatRoom.indexOf('@')));nameChatRoom=document.getElementById(nameChatRoom+'__roomChat__participants');nameChatRoom.appendChild(_UserChatRoom);}} 
    114111else 
    115112{if(type=='unavailable') 
    116 {var nodeUser="";if(xquery[i].firstChild.getAttribute('jid')!=null) 
    117 nodeUser=document.getElementById(nameChatRoom+"_UserChatRoom__"+xquery[i].firstChild.getAttribute('jid'));else 
    118 nodeUser=document.getElementById(nameChatRoom+"_UserChatRoom__"+xquery[i].parentNode.getAttribute('to'));nodeUser.parentNode.removeChild(nodeUser);} 
     113{nodeUser.parentNode.removeChild(nodeUser);} 
    119114else if(show) 
    120 {var _UserChatRoom=document.getElementById(nameChatRoom+"_UserChatRoom__"+xquery[i].firstChild.getAttribute('jid')) 
    121 _UserChatRoom.setAttribute("style","padding-left:18px ; margin:3px 0px 0px 2px; background: url('"+path_jabberit+"templates/default/images/"+show+".gif')no-repeat center left");}}}}}},onMessage:function(msg) 
     115{nodeUser.setAttribute("style","padding-left:18px ; margin:3px 0px 0px 2px; background: url('"+path_jabberit+"templates/default/images/"+show+".gif')no-repeat center left");}}}}}},onMessage:function(msg) 
    122116{var checkTime=function(i) 
    123117{if(i<10)i="0"+i;return i;};var messageDate=function(_date) 
     
    178172{if(!TrophyIM.sendMessageChatRoom(jidChatRoom,_textarea.value)) 
    179173return false;_textarea.value='';_textarea.focus();};loadscript.configEvents(_send,'onclick',_send_message);loadscript.configEvents(_leaveChatRoom,'onclick',function() 
    180 {TrophyIM.leaveChatRoom(jidChatRoom);setTimeout(function() 
     174{TrophyIM.leaveChatRoom(jidChatRoom);if(TrophyIM.activeChatRoom.name.length>0) 
     175{for(var i=0;i<TrophyIM.activeChatRoom.name.length;i++) 
     176{if(TrophyIM.activeChatRoom.name[i].indexOf(jidChatRoom)>=0) 
     177{TrophyIM.activeChatRoom.name[i]="";}}} 
     178setTimeout(function() 
    181179{_winBuild('window_chat_room_'+jidChatRoom,'remove');},500);});loadscript.configEvents(_textarea,'onkeyup',function(e) 
    182180{if(e.keyCode==13) 
     
    200198{var presence=$pres({from:TrophyIM.connection.jid,to:roomName}).c("x",{xmlns:Strophe.NS.MUC});TrophyIM.connection.send(presence);},leaveChatRoom:function(roomName) 
    201199{var room_nick=roomName;var presenceid=TrophyIM.connection.getUniqueId();var presence=$pres({type:"unavailable",id:presenceid,from:TrophyIM.connection.jid,to:room_nick}).c("x",{xmlns:Strophe.NS.MUC});TrophyIM.connection.send(presence);},getListRooms:function() 
     200{if(TrophyIM.statusConn.connected) 
    202201{var _error_return=function(element) 
    203 {alert(" ERROR : "+element);};var iq=$iq({to:"conference.im.pr.gov.br",type:"get"}).c("query",{xmlns:Strophe.NS.DISCO_ITEMS});TrophyIM.connection.sendIQ(iq,loadscript.listRooms,_error_return,500);},removeContact:function(jidTo) 
     202{alert("ERRO : Tente novamente !");};var iq=$iq({to:TROPHYIM_CHATROOM,type:"get"}).c("query",{xmlns:Strophe.NS.DISCO_ITEMS});TrophyIM.connection.sendIQ(iq,loadscript.listRooms,_error_return,500);}else 
     203alert("ERRO : Sem conexão com o servidor "+TROPHYIM_CHATROOM);},removeContact:function(jidTo) 
    204204{var divItenContact=null;if((divItenContact=document.getElementById('itenContact_'+jidTo))) 
    205205{var _id=TrophyIM.connection.getUniqueId();var delContact=$iq({type:'set',id:_id}) 
     
    298298{TrophyIM.makeChat(fulljid);},setAutorization:function(jidTo,jidFrom,_typeSubscription) 
    299299{var _id=TrophyIM.connection.getUniqueId();TrophyIM.connection.send($pres().attrs({from:jidFrom,to:jidTo,type:_typeSubscription,id:_id}).tree());},setPresence:function(_type) 
    300 {if(_type!='status') 
     300{var presence_chatRoom="";if(_type!='status') 
    301301{if(_type=="unavailable"&&TrophyIM.statusConn.connected) 
    302302{var loading_gif=document.getElementById("JabberIMRosterLoadingGif");if(TrophyIM._timeOut.renderRoster!=null) 
     
    314314{if(TrophyIM.statusConn.connected) 
    315315{if(loadscript.getStatusMessage()!="") 
    316 {var _presence=$pres();_presence.node.appendChild(Strophe.xmlElement('show')).appendChild(Strophe.xmlTextNode(_type));_presence.node.appendChild(Strophe.xmlElement('status')).appendChild(Strophe.xmlTextNode(loadscript.getStatusMessage()));TrophyIM.connection.send(_presence.tree());} 
    317 else 
    318 {TrophyIM.connection.send($pres().c('show').t(_type).tree());}}}}} 
     316{var _presence=$pres();_presence.node.appendChild(Strophe.xmlElement('show')).appendChild(Strophe.xmlTextNode(_type));_presence.node.appendChild(Strophe.xmlElement('status')).appendChild(Strophe.xmlTextNode(loadscript.getStatusMessage()));TrophyIM.connection.send(_presence.tree());presence_chatRoom=_type;} 
     317else 
     318{TrophyIM.connection.send($pres().c('show').t(_type).tree());presence_chatRoom=_type;}}}}} 
    319319else 
    320320{var _show="available";var _status="";if(arguments.length<2) 
     
    330330_show=TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence[resource].show;} 
    331331if(TrophyIM.statusConn.connected) 
    332 {var _presence=$pres();_presence.node.appendChild(Strophe.xmlElement('show')).appendChild(Strophe.xmlTextNode(_show));_presence.node.appendChild(Strophe.xmlElement('status')).appendChild(Strophe.xmlTextNode(_status));TrophyIM.connection.send(_presence.tree());}}},sendMessage:function() 
     332{var _presence=$pres();_presence.node.appendChild(Strophe.xmlElement('show')).appendChild(Strophe.xmlTextNode(_show));_presence.node.appendChild(Strophe.xmlElement('status')).appendChild(Strophe.xmlTextNode(_status));TrophyIM.connection.send(_presence.tree());presence_chatRoom=_show;}} 
     333if(TrophyIM.activeChatRoom.name.length>0) 
     334{for(var i in TrophyIM.activeChatRoom.name) 
     335{if(TrophyIM.activeChatRoom.name[i]!="") 
     336TrophyIM.connection.send($pres({to:TrophyIM.activeChatRoom.name[i]}).c('show').t(presence_chatRoom));}}},sendMessage:function() 
    333337{if(arguments.length>0) 
    334338{var jidTo=arguments[0];var message_input=arguments[1];message_input=message_input.replace(/^\s+|\s+$|^\n|\n$/g,"");if(message_input!=""){var newMessage=$msg({to:jidTo,from:TrophyIM.connection.jid,type:'chat'});newMessage=newMessage.c('body').t(message_input);newMessage.up();newMessage=newMessage.c('active').attrs({xmlns:'http://jabber.org/protocol/chatstates'});TrophyIM.connection.send(newMessage.tree());return true;}} 
Note: See TracChangeset for help on using the changeset viewer.