- Timestamp:
- 04/19/10 15:40:39 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js
r2577 r2584 147 147 chatHistory : {}, 148 148 149 /** Object: activeChats150 *151 * This object stores the currently active chats.152 */153 activeChats : {current: null, divs: {}},154 155 149 /** Function: setCookie 156 150 * … … 369 363 var password = arguments[1]; 370 364 371 TrophyIM.connection.connect( barejid + TROPHYIM_RESOURCE, password, TrophyIM.onConnect);365 TrophyIM.connection.connect( barejid + TROPHYIM_RESOURCE, password, TrophyIM.onConnect ); 372 366 } 373 367 else … … 393 387 394 388 TrophyIM.setCookie('trophyimjid', barejid); 395 396 389 }, 397 390 … … 403 396 { 404 397 TrophyIM.delCookie('trophyim_bosh_xid'); 398 405 399 delete TrophyIM['cookies']['trophyim_bosh_xid']; 406 400 407 if (TrophyIM.JSONStore.store_working)408 {409 TrophyIM.JSONStore.delData(['groups','roster', 'active_chat', 'chat_history']);410 }411 412 for (var chat in TrophyIM.activeChats['divs'])413 {414 delete TrophyIM.activeChats['divs'][chat];415 }416 417 TrophyIM.activeChats = {current: null, divs: {}},418 401 TrophyIM.connection.disconnect(); 419 402 TrophyIM.showLogin(); 403 }, 404 405 /** Function onConnect 406 * 407 * Callback given to Strophe upon connection to BOSH proxy. 408 */ 409 onConnect : function(status) 410 { 411 if( status == Strophe.Status.CONNECTING ) 412 { 413 Strophe.info('Strophe is connecting.'); 414 } 420 415 421 }, 422 423 /** Function onConnect 424 * 425 * Callback given to Strophe upon connection to BOSH proxy. 426 */ 427 onConnect : function(status) 428 { 429 if (status == Strophe.Status.CONNECTING) 430 { 431 Strophe.info('Strophe is connecting.'); 432 } 433 434 if (status == Strophe.Status.CONNFAIL) 416 if( status == Strophe.Status.CONNFAIL ) 435 417 { 436 418 Strophe.info('Strophe failed to connect.'); … … 439 421 } 440 422 441 if (status == Strophe.Status.DISCONNECTING)423 if( status == Strophe.Status.DISCONNECTING ) 442 424 { 443 425 Strophe.info('Strophe is disconnecting.'); 444 426 } 445 427 446 if (status == Strophe.Status.DISCONNECTED)428 if( status == Strophe.Status.DISCONNECTED ) 447 429 { 448 430 Strophe.info('Strophe is disconnected.'); … … 451 433 } 452 434 453 if (status == Strophe.Status.CONNECTED)435 if( status == Strophe.Status.CONNECTED ) 454 436 { 455 437 loadIM.setStatusJabber('Disponível','available'); … … 693 675 */ 694 676 695 addContact : function( jid From, jidTo, name, group )677 addContact : function( jidTo, name, group ) 696 678 { 697 679 // Add Contact … … 724 706 }, 725 707 708 /** Function : renameContact 709 * 710 * 711 */ 712 713 renameContact : function( jid, index ) 714 { 715 // Name 716 var name = TrophyIM.rosterObj.roster[jid].contact.name; 717 718 if(( name = prompt("Informe um novo nome para " + name + "!", name ))) 719 if(( name = name.replace(/^\s+|\s+$|^\n|\n$/g,"")) == "" ) 720 name = ""; 721 722 if( name == null || name == "") 723 name = ""; 724 725 var jidTo = jid 726 var name = ( name ) ? name : TrophyIM.rosterObj.roster[jid].contact.name; 727 var group = TrophyIM.rosterObj.roster[jid].contact.groups[0]; 728 729 TrophyIM.addContact( jidTo, name, group ); 730 731 document.getElementById('itenContact_' + jid + '_' + index).innerHTML = name; 732 }, 733 734 /** Function : renameGroup 735 * 736 * 737 */ 738 739 renameGroup : function( jid, index) 740 { 741 var group = TrophyIM.rosterObj.roster[jid].contact.groups[0]; 742 var presence = TrophyIM.rosterObj.roster[jid].presence; 743 744 // Group 745 if(( group = prompt("Informe um novo grupo ou deixe em branco", group ))) 746 if(( group = group.replace(/^\s+|\s+$|^\n|\n$/g,"")) == "" ) 747 group = ""; 748 749 if( group == null || group == "") 750 group = ""; 751 752 var jidTo = TrophyIM.rosterObj.roster[jid].contact.jid; 753 var name = TrophyIM.rosterObj.roster[jid].contact.name; 754 var group = ( group ) ? group : TrophyIM.rosterObj.roster[jid].contact.groups[0]; 755 756 TrophyIM.rosterObj.removeContact( jid ); 757 758 TrophyIM.addContact( jidTo, name, group ); 759 760 document.getElementById("JabberIMRoster").innerHTML = ""; 761 762 TrophyIM.renderRoster(); 763 764 setTimeout(function() 765 { 766 for( var i in presence ) 767 TrophyIM.rosterObj.setPresence( jid, presence[i].priority, presence[i].show, presence[i].status); 768 },500); 769 }, 770 726 771 /** Function: removeContact 727 772 * … … 1000 1045 var statusDisplay = "none"; 1001 1046 1002 if ( objContact.presence)1047 if ( objContact.presence ) 1003 1048 { 1004 1049 for ( var resource in objContact.presence ) … … 1264 1309 this.addContact = function(jid, subscription, name, groups ) 1265 1310 { 1266 1311 if( subscription !== "remove" ) 1267 1312 { 1268 1313 var contact = { jid:jid, subscription:subscription, name:name, groups:groups } 1269 1314 var jid_lower = jid.toLowerCase(); 1270 1315 … … 1277 1322 this.roster[jid_lower] = {contact:contact}; 1278 1323 } 1279 1324 1280 1325 groups = groups ? groups : ['']; 1281 1326 … … 1290 1335 } 1291 1336 } 1292 else1337 else 1293 1338 { 1294 1339 this.removeContact(jid); … … 1433 1478 if (!this.roster[jid_lower]['presence']) 1434 1479 { 1435 this.roster[jid_lower]['presence'] = {} 1436 } 1437 this.roster[jid_lower]['presence'][resource] = presence 1480 this.roster[jid_lower]['presence'] = {}; 1481 } 1482 this.roster[jid_lower]['presence'][resource] = presence; 1438 1483 } 1439 1484 else if (this.roster[jid_lower] && this.roster[jid_lower]['presence'] && this.roster[jid_lower]['presence'][resource]) … … 1687 1732 */ 1688 1733 1689 /*1690 var oldonload = window.onload;1691 window.onload = function()1692 {1693 if(oldonload)1694 {1695 oldonload();1696 }1697 1698 TrophyIM.load();1699 };1700 */1701 1702 1734 var oldonunload = window.onunload; 1735 1703 1736 window.onunload = function() 1704 1737 { 1705 if(oldonunload)1738 if( oldonunload ) 1706 1739 { 1707 1740 oldonunload(); 1708 1741 } 1709 1710 TrophyIM.storeData(); 1742 1743 //TrophyIM.storeData(); 1744 1745 TrophyIM.logout(); 1711 1746 }
Note: See TracChangeset
for help on using the changeset viewer.