Changeset 2787
- Timestamp:
- 05/14/10 14:53:17 (14 years ago)
- Location:
- sandbox/jabberit_messenger/trophy_expresso
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/jabberit_messenger/trophy_expresso/js/jscode/loadIM.js
r2754 r2787 15 15 var Xtools = null; 16 16 var zIndex = 9001; 17 var windowPopUp = null; 18 17 var windowPopUp = []; 18 19 // Sniffer Browser 20 var agt = navigator.userAgent.toLowerCase(); 21 var is_major = parseInt(navigator.appVersion); 22 var is_minor = parseFloat(navigator.appVersion); 23 var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) 24 && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) 25 && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)); 26 var is_gecko = (agt.indexOf('gecko') != -1); 27 var is_gecko1_5 = (agt.indexOf('firefox/1.5') != -1 || agt.indexOf('firefox/2') != -1 || agt.indexOf('iceweasel/2') != -1); 28 var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)); 29 var is_ie3 = (is_ie && (is_major < 4)); 30 var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) ); 31 var is_ie4up = (is_ie && (is_major >= 4)); 32 var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) ); 33 var is_ie5_5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1)); 34 var is_ie5up = (is_ie && !is_ie3 && !is_ie4); 35 var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5); 36 var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) ); 37 var is_ie6up = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5); 38 var is_win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) ); 39 19 40 // Images 20 41 var add_user = new Image(); … … 68 89 TrophyIM.rosterClick(jid); 69 90 } 91 92 setTimeout(function() 93 { 94 window.document.oncontextmenu = function() 95 { 96 return true; 97 }; 98 99 },500); 70 100 } 71 101 } … … 223 253 { 224 254 if ( pEvent.substring(0, 2) == 'on' ) 225 pEvent = pEvent.substring(2, pEvent.length); 226 227 if ( pObj.addEventListener ) 228 pObj.addEventListener(pEvent, pHandler, false); 229 else if ( pObj.attachEvent ) 230 pObj.attachEvent('on' + pEvent, pHandler); 255 pEvent = pEvent.substring(2, pEvent.length ); 256 257 if ( arguments.length == 3 ) 258 { 259 if ( pObj.addEventListener ) 260 pObj.addEventListener(pEvent, pHandler, false ); 261 else if ( pObj.attachEvent ) 262 pObj.attachEvent( 'on' + pEvent, pHandler ); 263 } 264 else if ( arguments.length == 4 ) 265 { 266 if ( pObj.removeEventListener ) 267 pObj.removeEventListener( pEvent, pHandler, false ); 268 else if ( pObj.detachEvent ) 269 pObj.detachEvent( 'on' + pEvent, pHandler ); 270 } 231 271 } 232 272 } … … 281 321 } 282 322 323 function getIsIE() 324 { 325 return is_ie; 326 } 327 283 328 function getPhotoUser( jid ) 284 329 { 330 try 331 { 285 332 var _divPhoto = getElement( jid + '__photo' ); 286 333 … … 292 339 _divPhoto.style.backgroundImage = 'url(' + _imgUser + ')'; 293 340 } 341 } 342 catch(e) 343 {} 294 344 } 295 345 … … 452 502 function notificationNewMessage() 453 503 { 454 var oldTitle = document.title; 504 var _doc = document; 505 var _id = arguments[0]; 506 var _win_name = _id.replace( /\W/g, '' ); 507 508 if ( windowPOPUP( _id ) ) 509 { 510 _doc = windowPopUp[_win_name].document; 511 } 512 513 var oldTitle = _doc.title; 455 514 var newTitle = "## NOVA MENSAGEM ##"; 456 var idWindow = arguments[1];457 515 458 516 if( timeoutId == null ) … … 460 518 timeoutId = setInterval(function() 461 519 { 462 document.title = ( document.title == newTitle ) ? oldTitle : newTitle;520 _doc.title = ( _doc.title == newTitle ) ? oldTitle : newTitle; 463 521 }, 1000); 464 522 465 configEvents( window.document, 'onclick', function()523 configEvents( _doc, 'onclick', function() 466 524 { 467 525 clearInterval(timeoutId); 468 document.title = oldTitle;526 _doc.title = oldTitle; 469 527 timeoutId = null; 470 528 }); 471 529 472 configEvents( window.document, 'onkeypress', function()530 configEvents( _doc, 'onkeypress', function() 473 531 { 474 532 clearInterval(timeoutId); 475 document.title = oldTitle;533 _doc.title = oldTitle; 476 534 timeoutId = null; 477 535 }); … … 524 582 525 583 window.document.body.appendChild(_optionsItens); 526 527 528 setTimeout(function()529 {530 window.document.oncontextmenu = function()531 {532 return true;533 };534 535 },500);536 584 } 537 585 } … … 682 730 function rosterDiv() 683 731 { 684 var _popUp = (_preferencesIM[1]).split(":"); 685 686 var paramListContact = 687 { 688 'idUser' : Base64.decode(getUserCurrent().jid), 689 'full_name' : (( fullName.length < 25 ) ? fullName : ( fullName.substring( 0, 25) + "...")), 690 'path_jabberit' : path_jabberit, 691 'zIndex_' : zIndex++ 692 }; 693 694 var winRosterDiv = 695 { 696 id_window : "window_Roster_im", 697 width : 250, 698 height : 410, 699 top : 50, 700 left : -1500, 701 leftOld : 50, 702 draggable : true, 703 visible : "display", 704 resizable : true, 705 zindex : zIndex++, 706 title : "Expresso Messenger - Contatos", 707 closeAction : "hidden", 708 content : Xtools.parse(Xtools.xml("contacts_list"),"contactsList.xsl", paramListContact) 709 }; 710 711 if( _preferencesIM[0] == "openWindowJabberit:false" ) 712 { 713 winRosterDiv.left = 50; 714 winRosterDiv.leftOld = -1500; 715 } 716 717 _winBuild( winRosterDiv ); 718 719 // Photo User 720 getPhotoUser(Base64.decode(getUserCurrent().jid)); 721 732 var _rosterDiv = function() 733 { 734 var _popUp = (_preferencesIM[1]).split(":"); 735 var _idUser = Base64.decode(getUserCurrent().jid); 736 737 var paramListContact = 738 { 739 'idUser' : _idUser, 740 'full_name' : (( fullName.length < 25 ) ? fullName : ( fullName.substring( 0, 25) + "...")), 741 'path_jabberit' : path_jabberit, 742 'zIndex_' : zIndex++ 743 }; 744 745 var winRosterDiv = 746 { 747 id_window : "window_Roster_im", 748 width : 250, 749 height : 410, 750 top : 50, 751 left : -1500, 752 leftOld : 50, 753 draggable : true, 754 visible : "display", 755 resizable : true, 756 zindex : zIndex++, 757 title : "Expresso Messenger - Contatos", 758 closeAction : "hidden", 759 content : Xtools.parse(Xtools.xml("contacts_list"),"contactsList.xsl", paramListContact) 760 }; 761 762 if( _preferencesIM[0] == "openWindowJabberit:false" ) 763 { 764 winRosterDiv.left = 50; 765 winRosterDiv.leftOld = -1500; 766 } 767 768 _winBuild( winRosterDiv ); 769 770 // Photo User 771 getPhotoUser(_idUser); 772 773 } 774 775 setTimeout( function(){ _rosterDiv(); }, 500 ); 722 776 } 723 777 … … 1014 1068 } 1015 1069 1070 var _stylesheets = [ ]; 1071 var _links = document.getElementsByTagName( 'link' ); 1072 1073 for ( var i = 0; i < _links.length; i++ ) 1074 if ( _links.item( i ).type && _links.item( i ).type.toLowerCase( ) == 'text/css' ) 1075 _stylesheets[ _stylesheets.length ] = _links.item( i ); 1076 1077 function windowPOPUP() 1078 { 1079 var _id = arguments[0]; 1080 var _win_name = _id.replace( /\W/g, '' ); 1081 1082 if ( arguments.length == 1 ) 1083 { 1084 if ( windowPopUp[_win_name] ) 1085 return true; 1086 else 1087 return false; 1088 } 1089 1090 if( arguments.length == 2 ) 1091 { 1092 if( !windowPopUp[_win_name] ) 1093 { 1094 windowPopUp[_win_name] = window.open( '', _win_name + '__popup', 'height=355,width=380,top=50,left=50,toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no,titlebar=no'); 1095 var tmp = windowPopUp[_win_name].document; 1096 1097 tmp.write('<html><head>'); 1098 tmp.write('</head><body>'); 1099 tmp.write('</body></html>'); 1100 tmp.close(); 1101 1102 for ( var i = 0; i < _stylesheets.length; i++ ) 1103 tmp.documentElement.getElementsByTagName( 'head' ).item(0).appendChild( _stylesheets[ i ].cloneNode( true ) ); 1104 1105 var divPOP = getElement( _id + "__popUp" ); 1106 divPOP.style.background = "url('"+path_jabberit+"templates/default/images/icon_down.png') no-repeat"; 1107 divPOP.innerHTML = "PopIn"; 1108 1109 function _close( ) 1110 { 1111 windowPopUp[_win_name].close(); 1112 configEvents( divPOP ,'onclick', _close, true ); 1113 } 1114 1115 configEvents( divPOP ,'onclick', _close ); 1116 1117 var _content = tmp.documentElement.getElementsByTagName( 'body' ).item(0).appendChild( getElement(_id + '__chatBox' ).parentNode ); 1118 1119 _content.firstChild.scrollTop = _content.firstChild.scrollHeight; 1120 1121 configEvents( windowPopUp[_win_name] ,'onbeforeunload', function() 1122 { 1123 delete windowPopUp[_win_name]; 1124 divPOP.style.background = "url('"+path_jabberit+"templates/default/images/icon_up.png') no-repeat"; 1125 divPOP.innerHTML = "PopOut"; 1126 divPOP.onclick = function(){ loadscript.windowPOPUP( _id , true ); }; 1127 _winBuild( 'window_chat_area_' + _id, "display" ).content( true ); 1128 }); 1129 1130 _winBuild( 'window_chat_area_' + _id, 'hidden' ); 1131 } 1132 } 1133 } 1134 1016 1135 function loadIM() 1017 1136 { … … 1085 1204 loadIM.prototype.clrAllContacts = clrAllContacts; 1086 1205 loadIM.prototype.configEvents = configEvents; 1206 loadIM.prototype.getIsIE = getIsIE; 1087 1207 loadIM.prototype.getPhotoUser = getPhotoUser; 1088 1208 loadIM.prototype.getStatusMessage = getStatusMessage; … … 1111 1231 loadIM.prototype.renameGroup = renameGroup; 1112 1232 loadIM.prototype.rosterDiv = rosterDiv; 1233 loadIM.prototype.windowPOPUP = windowPOPUP; 1113 1234 1114 1235 window.LoadIM = loadIM; -
sandbox/jabberit_messenger/trophy_expresso/js/makeW.js
r2750 r2787 4 4 var dragDrop = null; 5 5 var path = path_jabberit; 6 7 var _dialogs = [ ]; 6 8 7 9 function build(pObj) … … 35 37 window.document.body.insertBefore( _window, document.body.lastChild ); 36 38 37 getElement(pObj.id_window + '__content').innerHTML = pObj.content; 39 if ( pObj.content.constructor == String ) 40 getElement(pObj.id_window + '__content').innerHTML = pObj.content; 41 else 42 getElement(pObj.id_window + '__content').appendChild( pObj.content ); 43 44 _dialogs[ pObj.id_window ] = getElement(pObj.id_window + '__content').firstChild; 38 45 39 46 if( pObj.draggable ) … … 45 52 else 46 53 { 47 load(pObj.id_window, "display"); 54 if ( pObj.barejid && loadscript.windowPOPUP( pObj.barejid ) ) 55 return false; 56 57 load(pObj.id_window, "display"); 48 58 } 49 59 } … … 83 93 if( arguments.length > 0 ) 84 94 { 95 var pId = null; 85 96 if( arguments.length == 1 ) 86 97 { 87 98 var obj = arguments[0]; 99 pId = obj.id_window 88 100 build(obj); 89 101 } … … 91 103 if( arguments.length == 2 ) 92 104 { 93 load( arguments[0], arguments[1]);105 load( ( pId = arguments[0] ), arguments[1]); 94 106 } 95 107 } 108 109 return ( new function( ) 110 { 111 this.content = function( ) 112 { 113 if ( arguments.length ) 114 getElement( pId + '__content').appendChild( _dialogs[ pId ] ); 115 116 return _dialogs[ obj.id_window ]; 117 }; 118 } ); 96 119 } 97 120 … … 105 128 { 106 129 if( arguments.length == 1 ) 107 _win = newbWindow( arguments[0] );130 return bWindow( arguments[0] ); 108 131 109 132 if( arguments.length == 2 ) 110 _win = newbWindow( arguments[0], arguments[1]);133 return bWindow( arguments[0], arguments[1]); 111 134 } 135 return false; 112 136 } -
sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js
r2750 r2787 252 252 253 253 //Load other .js scripts needed 254 //document.getElementsByTagName('head')[0].appendChild(DOMObjects.getScript(path_jabberit + 'js/strophe.min.js'));255 document.getElementsByTagName('head')[0].appendChild(DOMObjects.getScript(path_jabberit + 'js/strophe.js'));254 document.getElementsByTagName('head')[0].appendChild(DOMObjects.getScript(path_jabberit + 'js/strophe.min.js')); 255 //document.getElementsByTagName('head')[0].appendChild(DOMObjects.getScript(path_jabberit + 'js/strophe.js')); 256 256 document.getElementsByTagName('head')[0].appendChild(DOMObjects.getScript(path_jabberit + 'js/json2.js')); //Keep this script last 257 257 … … 652 652 var elems = msg.getElementsByTagName('body'); 653 653 var delay = ( msg.getElementsByTagName('delay') ) ? msg.getElementsByTagName('delay') : null; 654 var stamp = ( delay[0] != null ) ? messageDate(delay[0].getAttribute('stamp')): dtNow;654 var stamp = ( delay[0] != null ) ? "<font style='color:red;'>" + messageDate(delay[0].getAttribute('stamp')) + "</font>" : dtNow; 655 655 656 656 var barejid = Strophe.getBareJidFromJid(from); … … 702 702 }; 703 703 704 TrophyIM.makeChat(from); //Make sure we have a chat window 705 TrophyIM.addMessage( message, jid_lower ); 704 TrophyIM.addMessage( TrophyIM.makeChat( from ), jid_lower, message ); 706 705 } 707 706 } 708 707 } 709 // 708 //Message without body are "content message", this mean state is not active 710 709 else 711 710 { … … 773 772 var barejid = Strophe.getBareJidFromJid(fulljid); 774 773 var titleWindow = ""; 775 774 776 775 var paramsChatBox = 777 776 { 777 'enabledPopUp' : ( ( loadscript.getIsIE() ) ? "none" : "block" ), 778 778 'idChatBox' : barejid + "__chatBox", 779 779 'jidTo' : barejid, … … 802 802 TrophyIM.posWindow.left = 400; 803 803 804 var _content = document.createElement( 'div' ); 805 _content.innerHTML = loadscript.parse( "chat_box", "chatBox.xsl", paramsChatBox); 806 _content = _content.firstChild; 807 808 var _messages = _content.firstChild.firstChild; 809 var _textarea = _content.getElementsByTagName( 'textarea' ).item( 0 ); 810 var _send = _content.getElementsByTagName( 'input' ).item( 0 ); 811 812 function _send_message( ) 813 { 814 if ( ! TrophyIM.sendMessage( barejid, _textarea.value ) ) 815 return false; 816 817 // Add Message in chatBox; 818 TrophyIM.addMessage( _messages, barejid, { 819 contact : "<font style='font-weight:bold; color:red;'>" + "Eu" + "</font>", 820 msg : "<br/>" + _textarea.value 821 } ); 822 823 _textarea.value = ''; 824 _textarea.focus( ); 825 } 826 827 loadscript.configEvents( _send, 'onclick', _send_message ); 828 loadscript.configEvents( _textarea, 'onkeyup', function( e ) 829 { 830 if ( e.keyCode == 13 ) 831 _send_message( ); 832 } ); 833 804 834 var winChatBox = 805 835 { 806 836 id_window : "window_chat_area_" + barejid, 837 barejid : barejid, 807 838 width : 387, 808 839 height : 375, … … 815 846 title : titleWindow, 816 847 closeAction : "hidden", 817 content : loadscript.parse("chat_box","chatBox.xsl", paramsChatBox)848 content : _content 818 849 } 819 850 820 851 _win = _winBuild(winChatBox); 821 852 822 853 // Notification New Message 823 loadscript.notification( );854 loadscript.notification(barejid); 824 855 825 856 // Photo User; 826 857 loadscript.getPhotoUser(barejid); 827 828 loadscript.configEvents( document.getElementById( barejid + '__sendBox'), 829 'onkeyup', function(e) 830 { 831 if( e.keyCode == 13 ) 832 { 833 TrophyIM.sendMessage( barejid ); 834 document.getElementById( barejid + '__sendBox').value = ''; 835 return false; 836 } 837 } 838 ); 858 859 _textarea.focus( ); 860 861 return ( _messages = _win.content( ).firstChild ); 839 862 }, 840 863 … … 867 890 */ 868 891 869 addMessage : function( msg, jid)892 addMessage : function(chatBox, jid, msg) 870 893 { 871 var chatBox = document.getElementById(jid + "__chatBox");872 894 var messageDiv = document.createElement("div"); 873 874 895 messageDiv.style.margin = "3px 0px 1em 3px"; 875 896 messageDiv.innerHTML = msg.contact + " : " + msg.msg ; … … 1394 1415 }, 1395 1416 1396 1397 1417 /** Function SetAutorization 1398 1418 * … … 1517 1537 */ 1518 1538 1519 sendMessage : function( )1539 sendMessage : function( _jidTo, _message ) 1520 1540 { 1521 1522 if( arguments.length > 0 ) 1523 { 1524 var jidTo = arguments[0]; 1525 var message_input = document.getElementById(jidTo + "__sendBox").value; 1526 1527 if( ( message_input = message_input.replace(/^\s+|\s+$|^\n|\n$/g,"") ) != "" ) 1528 { 1529 // Send Message 1530 TrophyIM.connection.send($msg({to: jidTo, from: TrophyIM.connection.jid, type: 'chat'}).c('body').t(message_input).tree()); 1531 1532 var message = 1533 { 1534 contact : "<font style='font-weight:bold; color:red;'>" + "Eu" + "</font>", 1535 msg : "<br/>" + message_input 1536 } 1537 1538 // Add Message in chatBox; 1539 TrophyIM.addMessage( message, jidTo); 1540 document.getElementById(jidTo + "__sendBox").value = ""; 1541 document.getElementById(jidTo + "__sendBox").focus(); 1542 } 1543 } 1541 _message = _message.replace(/^\s+|\s+$|^\n|\n$/g,""); 1542 1543 if( _message != "" ) 1544 { 1545 // Send Message 1546 TrophyIM.connection.send( 1547 $msg( { 1548 to: _jidTo, from: TrophyIM.connection.jid, 1549 type: 'chat' 1550 } ).c('body').t( _message ).tree() 1551 ); 1552 return true; 1553 } 1554 1555 return false; 1544 1556 } 1545 1557 }; -
sandbox/jabberit_messenger/trophy_expresso/js/xtools.js
r2670 r2787 91 91 for (var i in params ) 92 92 if ( params[ i ] && params[ i ].constructor != Function ) 93 xslProc.setParameter(null, i, params[i]);93 xslProc.setParameter(null, String( i ), String( params[i] ) ); 94 94 } 95 95 … … 113 113 var params = arguments[2]; 114 114 for (var i in params ) 115 xslProc.addParameter(i, params[i], ''); 115 if ( params[ i ] && params[ i ].constructor != Function ) 116 { 117 xslProc.addParameter( String( i ), String( params[i] ), ''); 118 } 116 119 } 117 120 -
sandbox/jabberit_messenger/trophy_expresso/xsl/chatBox.xsl
r2725 r2787 2 2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 3 3 <xsl:output method="html" omit-xml-declaration="yes"/> 4 4 5 <xsl:param name="enabledPopUp" /> 5 6 <xsl:param name="idChatBox" /> 6 7 <xsl:param name="jidTo" /> … … 17 18 <div id="{$jidTo}__photo" style="width:60px ;height:80px ;background-image:url('{$path_jabberit}templates/default/images/photo.png');" /> 18 19 <div style="margin: 7px 5px 5px 10px;"> 19 <input type="button" value="Send" onclick="TrophyIM.sendMessage('{$jidTo}')"/> 20 <input type="button" value="Send"/> 21 </div> 22 <div id="{$jidTo}__popUp" onclick="loadscript.windowPOPUP('{$jidTo}', true );" style="display:{$enabledPopUp}; cursor:pointer;padding-left:16px; font-size:10px ;height:14px; width:50px; background:url('{$path_jabberit}templates/default/images/icon_up.png') no-repeat;"> 23 PopUp 20 24 </div> 21 25 </div>
Note: See TracChangeset
for help on using the changeset viewer.