Changeset 2312 for sandbox/jabberit_messenger/trophy
- Timestamp:
- 03/19/10 17:28:03 (14 years ago)
- Location:
- sandbox/jabberit_messenger/trophy
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/jabberit_messenger/trophy/js/loadIM.js
r2293 r2312 5 5 var zIndex = 9001; 6 6 7 function configEvents(pObj, pEvent, pHandler) 8 { 9 if ( typeof pObj == 'object' ) 10 { 11 if ( pEvent.substring(0, 2) == 'on' ) 12 pEvent = pEvent.substring(2, pEvent.length); 13 14 if ( pObj.addEventListener ) 15 pObj.addEventListener(pEvent, pHandler, false); 16 else if ( pObj.attachEvent ) 17 pObj.attachEvent('on' + pEvent, pHandler); 18 } 19 } 20 7 21 function TrophyIMChatArea() 8 22 { 23 /* 9 24 var winImChatArea = 10 25 { … … 23 38 }; 24 39 25 //_winBuild( winImChatArea ); 26 27 //return '<div id="trophyimchat"><div id="trophyimchattabs"/></div>'; 40 _winBuild( winImChatArea ); 41 42 return '<div id="trophyimchat"><div id="trophyimchattabs"/></div>'; 43 */ 28 44 } 29 45 … … 83 99 { 84 100 setXTools(); 85 101 86 102 var winRosterDiv = 87 103 { … … 97 113 title : "Contatos - Expresso Messenger", 98 114 closeAction : "hidden", 99 content : '<div id="trophyimroster" />' + TrophyIMStatusDiv()115 content : _xtools.parse(_xtools.xml("contacts_list"),"contactsList.xsl") 100 116 }; 101 117 102 118 _winBuild( winRosterDiv ); 103 104 //return '<div id="trophyimroster" />';105 119 } 106 120 … … 123 137 { 124 138 var statusDiv = '<div id="trophyimstatus">' + 125 '<span>Status: </span>' +139 '<span>Status::::</span>' + 126 140 '<span id="trophyimstatuslist">Select box</span>' + 127 141 '<br/>' + … … 129 143 '<input type="button" value="disconnect" onclick="TrophyIM.logout()"/>' + 130 144 '</form>' + 145 '<input type="button" value="DND" onclick="TrophyIM.setTest(\'dnd\')">'+ 146 '<input type="button" value="AWAY" onclick="TrophyIM.setTest(\'away\')">'+ 147 '<input type="button" value="XA" onclick="TrophyIM.setTest(\'xa\')">'+ 148 '<input type="button" value="INVISIBLE" onclick="TrophyIM.setTest(\'invisible\')">'+ 149 '<input type="button" value="UNAVAILABLE" onclick="TrophyIM.setTest(\'unavailable\')">'+ 150 '<input type="button" value="AVAILABLE" onclick="TrophyIM.setTest(\'available\')">'+ 131 151 '</div>'; 132 152 … … 216 236 function loadIM() 217 237 { 218 219 238 var files = [ 220 239 'js/xtools.js', … … 222 241 'js/makeW.js', 223 242 'css/trophyim.css', 224 'css/window_azul.css'243 //'css/window_azul.css' 225 244 //'css/window_cataratas.css' 226 245 //'css/window_celepar.css' … … 229 248 //'css/window_escritorio.css' 230 249 //'css/window_metropole.css' 231 //'css/window_rochas.css'250 'css/window_rochas.css' 232 251 ]; 233 252 234 253 loadScripts(files); 235 236 254 } 237 255 … … 239 257 loadIM.prototype.getZIndex = getZindex; 240 258 loadIM.prototype.parse = parse; 259 loadIM.prototype.configEvents = configEvents; 241 260 242 261 loadIM.prototype.HTMLSnippets = new HTMLSnippets; -
sandbox/jabberit_messenger/trophy/js/trophyim.js
r2298 r2312 499 499 } 500 500 TrophyIM.rosterObj = new TrophyIMRoster(); 501 TrophyIM.connection.addHandler(TrophyIM.onVersion, Strophe.NS.VERSION, 502 'iq', null, null, null); 503 TrophyIM.connection.addHandler(TrophyIM.onRoster, Strophe.NS.ROSTER, 504 'iq', null, null, null); 505 TrophyIM.connection.addHandler(TrophyIM.onPresence, null, 'presence', 506 null, null, null); 507 TrophyIM.connection.addHandler(TrophyIM.onMessage, null, 'message', 508 null, null, null); 501 TrophyIM.connection.addHandler(TrophyIM.onVersion, Strophe.NS.VERSION, 'iq', null, null, null); 502 TrophyIM.connection.addHandler(TrophyIM.onRoster, Strophe.NS.ROSTER, 'iq', null, null, null); 503 TrophyIM.connection.addHandler(TrophyIM.onPresence, null, 'presence', null, null, null); 504 TrophyIM.connection.addHandler(TrophyIM.onMessage, null, 'message', null, null, null); 509 505 //Get roster then announce presence. 510 TrophyIM.connection.send($iq({type: 'get', xmlns: Strophe.NS.CLIENT}).c( 511 'query', {xmlns: Strophe.NS.ROSTER}).tree()); 506 TrophyIM.connection.send($iq({type: 'get', xmlns: Strophe.NS.CLIENT}).c('query', {xmlns: Strophe.NS.ROSTER}).tree()); 512 507 TrophyIM.connection.send($pres().tree()); 513 508 TrophyIM.renderChats(); … … 577 572 * Presence handler 578 573 */ 579 onPresence : function(msg) { 580 Strophe.debug("Presence handler"); 581 var type = msg.getAttribute('type') ? msg.getAttribute('type') : 582 'available'; 583 var show = msg.getElementsByTagName('show').length ? Strophe.getText( 584 msg.getElementsByTagName('show')[0]) : type; 585 var status = msg.getElementsByTagName('status').length ? Strophe.getText( 586 msg.getElementsByTagName('status')[0]) : ''; 587 var priority = msg.getElementsByTagName('priority').length ? parseInt( 588 Strophe.getText(msg.getElementsByTagName('priority')[0])) : 0; 589 TrophyIM.rosterObj.setPresence(msg.getAttribute('from'), priority, 590 show, status); 574 onPresence : function(msg) 575 { 576 //alert('Function onPresence'); 577 578 Strophe.debug("Presence handler"); 579 var type = msg.getAttribute('type') ? msg.getAttribute('type') : 'available'; 580 var show = msg.getElementsByTagName('show').length ? Strophe.getText(msg.getElementsByTagName('show')[0]) : type; 581 var status = msg.getElementsByTagName('status').length ? Strophe.getText(msg.getElementsByTagName('status')[0]) : ''; 582 var priority = msg.getElementsByTagName('priority').length ? parseInt(Strophe.getText(msg.getElementsByTagName('priority')[0])) : 0; 583 TrophyIM.rosterObj.setPresence(msg.getAttribute('from'), priority, show, status); 584 591 585 return true; 592 586 }, … … 678 672 id_window : "window_chat_area_" + barjid, 679 673 width : 387, 680 height : 3 55,674 height : 365, 681 675 top : 100, 682 676 left : 400, … … 691 685 692 686 _winBuild(winChatBox) 687 688 loadIM.configEvents( 689 document.getElementById( barjid + '__sendBox'), 690 'onkeyup', function(e) 691 { 692 if( e.keyCode == 13 ) 693 { 694 TrophyIM.sendMessage( barjid ); 695 document.getElementById( barjid + '__sendBox').value = ''; 696 return false; 697 } 698 } 699 ); 693 700 694 701 /* … … 762 769 * (String) tab_div - tab div element to alter class on 763 770 */ 764 setTabPresence : function(jid, tab_div) { 765 var presence = TrophyIM.rosterObj.getPresence(jid); 771 setTabPresence : function(jid, tab_div) 772 { 773 alert('function setTabPresence'); 774 775 var presence = TrophyIM.rosterObj.getPresence(jid); 766 776 tab_div.className = tab_div.className.replace(" trophyimchattab_av", ""); 767 777 tab_div.className = tab_div.className.replace(" trophyimchattab_aw", ""); … … 1060 1070 tab_item.parentNode.parentNode.removeChild(tab_item.parentNode); 1061 1071 }, 1062 /** Function: sendMessage 1072 1073 setPresence : function() 1074 { 1075 if( arguments.length > 0 ) 1076 { 1077 //alert('Args 0 : ' + arguments[0]); 1078 TrophyIM.connection.send($pres( ).c('show').t(arguments[0])); 1079 } 1080 }, 1081 1082 /** Function: sendMessage 1063 1083 * 1064 1084 * Send message from chat input to user … … 1071 1091 { 1072 1092 var jidTo = arguments[0]; 1073 var message_input = document.getElementById(jidTo + "__sendBox") ;1093 var message_input = document.getElementById(jidTo + "__sendBox").value; 1074 1094 1075 if( message_input.value.replace(/^\s+|\s+$/g,"") != "" )1095 if( ( message_input = message_input.replace(/^\s+|\s+$|^\n|\n$/g,"") ) != "" ) 1076 1096 { 1077 1097 // Send Message 1078 TrophyIM.connection.send($msg({to: jidTo, from: TrophyIM.connection.jid, type: 'chat'}).c('body').t(message_input .value).tree());1098 TrophyIM.connection.send($msg({to: jidTo, from: TrophyIM.connection.jid, type: 'chat'}).c('body').t(message_input).tree()); 1079 1099 1080 1100 var message = 1081 1101 { 1082 1102 contact : "<font style='font-weight:bold; color:red;'>" + "Eu" + "</font>", 1083 msg : message_input .value1103 msg : message_input 1084 1104 } 1085 1086 message_input.value = '';1087 1105 1088 1106 // Add Message in chatBox; … … 1194 1212 * (String) status: status attribute from presence 1195 1213 */ 1196 this.setPresence = function(fulljid, priority, show, status) { 1197 var barejid = Strophe.getBareJidFromJid(fulljid); 1214 this.setPresence = function(fulljid, priority, show, status) 1215 { 1216 var barejid = Strophe.getBareJidFromJid(fulljid); 1198 1217 var resource = Strophe.getResourceFromJid(fulljid); 1199 1218 var jid_lower = barejid.toLowerCase(); 1200 if(show != 'unavailable') { 1201 if (!this.roster[jid_lower]) { 1219 1220 if( show != 'unavailable') 1221 { 1222 if (!this.roster[jid_lower]) 1223 { 1202 1224 this.addContact(barejid, 'not-in-roster'); 1203 1225 } 1204 var presence = { 1226 var presence = 1227 { 1205 1228 resource:resource, priority:priority, show:show, status:status 1206 1229 } 1207 if (!this.roster[jid_lower]['presence']) { 1230 1231 if (!this.roster[jid_lower]['presence']) 1232 { 1208 1233 this.roster[jid_lower]['presence'] = {} 1209 1234 } 1210 1235 this.roster[jid_lower]['presence'][resource] = presence 1211 } else if (this.roster[jid_lower] && this.roster[jid_lower]['presence'] 1212 && this.roster[jid_lower]['presence'][resource]) { 1236 } 1237 else if (this.roster[jid_lower] && this.roster[jid_lower]['presence'] && this.roster[jid_lower]['presence'][resource]) 1238 { 1213 1239 delete this.roster[jid_lower]['presence'][resource]; 1214 1240 } 1215 this.addChange(jid_lower); 1216 if (TrophyIM.activeChats['divs'][jid_lower]) { 1217 TrophyIM.setTabPresence(jid_lower, 1218 TrophyIM.activeChats['divs'][jid_lower]['tab']); 1241 1242 this.addChange(jid_lower); 1243 1244 if (TrophyIM.activeChats['divs'][jid_lower]) 1245 { 1246 TrophyIM.setTabPresence(jid_lower, TrophyIM.activeChats['divs'][jid_lower]['tab']); 1219 1247 } 1220 1248 } -
sandbox/jabberit_messenger/trophy/xsl/chatBox.xsl
r2298 r2312 9 9 10 10 <div> 11 <div id="{$idChatBox}" style="height:190px; width:370px; overflow-y:scroll "></div>11 <div id="{$idChatBox}" style="height:190px; width:370px; overflow-y:scroll;"></div> 12 12 <div style="margin:2px;"> 13 <div style="margin-top:0px; width:70px; height:93px; position:relative; float:right; background-image:url('images/photo.png');"></div> 14 <textarea id="{$jidTo}__sendBox" class="trophyimchatinput" rows="5" cols="38"></textarea> 15 <div style="margin-left:2px;"> 13 <textarea id="{$jidTo}__sendBox" class="trophyimchatinput" style="padding-left: 78px; height:130px; width:285px;"></textarea> 14 <div style="position:relative;margin:-126px 0 0 3px; border:0px solid red;width:70px; height:93px; background-image:url('images/photo.png');"></div> 15 16 <div style="margin: 3px 0 0 4px;"> 16 17 <input type="button" value="Send" onclick="TrophyIM.sendMessage('{$jidTo}')"/> 17 18 </div>
Note: See TracChangeset
for help on using the changeset viewer.