- Timestamp:
- 04/16/10 18:15:47 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js
r2511 r2577 229 229 //Load other .js scripts needed 230 230 document.getElementsByTagName('head')[0].appendChild(DOMObjects.getScript(path_jabberit + 'strophejs/strophe.js')); 231 document.getElementsByTagName('head')[0].appendChild(DOMObjects.getScript(path_jabberit + 'strophejs/md5.js'));232 document.getElementsByTagName('head')[0].appendChild(DOMObjects.getScript(path_jabberit + 'strophejs/sha1.js'));233 document.getElementsByTagName('head')[0].appendChild(DOMObjects.getScript(path_jabberit + 'strophejs/b64.js'));234 231 document.getElementsByTagName('head')[0].appendChild(DOMObjects.getScript(path_jabberit + 'js/json2.js')); //Keep this script last 235 232 //Wait a second to give scripts time to load … … 553 550 } 554 551 555 TrophyIM.rosterObj.addContact(getAttribute('jid'), getAttribute('subscription'), getAttribute('name'), group_array); 552 if( getAttribute('ask') ) 553 TrophyIM.rosterObj.addContact(getAttribute('jid'), getAttribute('ask'), getAttribute('name'), group_array); 554 else 555 TrophyIM.rosterObj.addContact(getAttribute('jid'), getAttribute('subscription'), getAttribute('name'), group_array); 556 556 } 557 558 /*559 var groups = roster_items[i].getElementsByTagName('group');560 561 var group_array = new Array();562 563 for (var g = 0; g < groups.length; g++)564 {565 if( groups[g].firstChild != null )566 group_array[group_array.length] = groups[g].firstChild.nodeValue;567 }568 569 with ( roster_items[i] )570 {571 alert(getAttribute('jid') + "\n" + getAttribute('subscription') + "\n" + getAttribute('name'));572 TrophyIM.rosterObj.addContact(getAttribute('jid'), getAttribute('subscription'), getAttribute('name'), group_array);573 }574 */575 557 } 576 558 … … 713 695 addContact : function( jidFrom, jidTo, name, group ) 714 696 { 715 // Set Presence 716 var newPresence = $pres({from: jidFrom, to: jidTo, type: 'subscribe'}).tree(); 717 718 TrophyIM.connection.send(newPresence); 719 720 // Add Contact 697 // Add Contact 721 698 var _id = TrophyIM.connection.getUniqueId('add'); 722 699 var newContact = $iq({type: 'set', id: _id }); … … 767 744 768 745 divItenContact.parentNode.removeChild(divItenContact); 769 746 770 747 // Remove Contact 771 var _id = TrophyIM.connection.getUniqueId( 'del');748 var _id = TrophyIM.connection.getUniqueId(); 772 749 var delContact = $iq({type: 'set', id: _id}) 773 750 delContact = delContact.c('query').attrs({xmlns : 'jabber:iq:roster'}); 774 751 delContact = delContact.c('item').attrs({jid: jidTo, subscription:'remove'}).tree(); 775 776 TrophyIM.connection.send(delContact); 752 753 TrophyIM.connection.send( delContact ); 754 755 // Remove Contact 756 var _id = TrophyIM.connection.getUniqueId(); 757 var _delContact_ = $iq({type: 'set', id: _id}) 758 _delContact_ = _delContact_.c('query').attrs({xmlns : 'jabber:iq:private'}); 759 _delContact_ = _delContact_.c('storage').attrs({xmlns : 'storage:metacontacts'}).tree(); 760 761 TrophyIM.connection.send( _delContact_ ); 777 762 } 778 763 }, … … 920 905 presence = objContact.presence[resource].show; 921 906 907 if( objContact.contact.subscription != "both") 908 presence = 'subscription'; 909 922 910 if( objContact.presence[resource].status ) 923 911 { 924 status 912 status = " ( " + objContact.presence[resource].status + " ) "; 925 913 statusDisplay = "block"; 926 914 } … … 930 918 var paramsContact = 931 919 { 932 'nameContact' : nameContact, 933 'jid' : objContact.contact.jid, 934 'id' : 'itenContact_' + objContact.contact.jid + '_' + index , 935 'index' : index, 936 'path_jabberit' : path_jabberit, 937 'presence' : presence, 938 'status' : status, 939 'statusDisplay' : statusDisplay, 940 'subscription' : objContact.contact.subscription 920 nameContact : nameContact, 921 jid : objContact.contact.jid, 922 id : 'itenContact_' + objContact.contact.jid + '_' + index , 923 index : index, 924 path_jabberit : path_jabberit, 925 presence : presence, 926 status : status, 927 statusColor : "black", 928 statusDisplay : statusDisplay, 929 subscription : objContact.contact.subscription 930 } 931 932 933 934 // Authorization 935 if( objContact.contact.subscription != "both" ) 936 { 937 938 switch(objContact.contact.subscription) 939 { 940 case "none" : 941 942 paramsContact.status = " (( PEDIR AUTORIZAÇAO ! )) "; 943 paramsContact.statusColor = "red"; 944 break; 945 946 case "to" : 947 948 paramsContact.status = " (( CONTATO PEDE AUTORIZAÇÃO ! )) "; 949 paramsContact.statusColor = "orange"; 950 break; 951 952 case "from" : 953 954 paramsContact.status = " (( AUTORIZAR ? )) "; 955 paramsContact.statusColor = "green"; 956 break; 957 958 case "subscribe" : 959 960 paramsContact.status = " (( AUTORIZAÇÃO ENVIADA ! )) "; 961 paramsContact.statusColor = "red"; 962 break; 963 964 case "not-in-roster" : 965 966 paramsContact.status = " (( QUERO ADICIONÁ-LO(A) ! POSSO ? )) "; 967 paramsContact.statusColor = "orange"; 968 break; 969 970 default: 971 paramsContact.status = " ( " + objContact.contact.subscription + " ) "; 972 } 941 973 } 942 974 … … 961 993 else 962 994 { 995 963 996 // Presence e Status 964 997 var presence = "unavailable"; 965 998 var status = ""; 999 var statusColor = "black"; 966 1000 var statusDisplay = "none"; 967 1001 … … 973 1007 presence = objContact.presence[resource].show; 974 1008 1009 if( objContact.contact.subscription != "both") 1010 presence = 'subscription'; 1011 975 1012 if( objContact.presence[resource].status ) 976 1013 { 977 status 1014 status = " ( " + objContact.presence[resource].status + " ) "; 978 1015 statusDisplay = "block"; 979 1016 } … … 984 1021 is_open = is_open.indexOf("arrow_down.gif"); 985 1022 1023 // Authorization 1024 if( objContact.contact.subscription != "both" ) 1025 { 1026 switch(objContact.contact.subscription) 1027 { 1028 case "none" : 1029 1030 status = " (( PEDIR AUTORIZAÇAO ! )) "; 1031 statusColor = "red"; 1032 break; 1033 1034 case "to" : 1035 1036 status = " (( CONTATO PEDE AUTORIZAÇÃO ! )) "; 1037 statusColor = "orange"; 1038 break; 1039 1040 case "from" : 1041 1042 status = " (( AUTORIZAR ? )) "; 1043 statusColor = "green"; 1044 break; 1045 1046 case "subscribe" : 1047 1048 status = " (( AUTORIZAÇÃO ENVIADA ! )) "; 1049 statusColor = "red"; 1050 break; 1051 1052 case "not-in-roster" : 1053 1054 status = " (( QUERO ADICIONÁ-LO(A) ! POSSO ? )) "; 1055 statusColor = "orange"; 1056 break; 1057 1058 default: 1059 status = " ( " + objContact.contact.subscription + " ) "; 1060 } 1061 1062 statusDisplay = "block"; 1063 } 1064 986 1065 with ( document.getElementById('span_show_' + 'itenContact_' + objContact.contact.jid + '_' + index ) ) 987 1066 { … … 989 1068 { 990 1069 style.display = statusDisplay; 1070 style.color = statusColor; 991 1071 innerHTML = status; 992 1072 } … … 1186 1266 if( subscription !== "remove" ) 1187 1267 { 1188 1268 var contact = { jid:jid, subscription:subscription, name:name, groups:groups } 1189 1269 var jid_lower = jid.toLowerCase(); 1190 1270 … … 1295 1375 this.removeContact = function(jid) 1296 1376 { 1297 var groups = this.roster[ jid ].contact.groups; 1377 if( this.roster[ jid ] ) 1378 { 1379 var groups = this.roster[ jid ].contact.groups; 1380 1381 if( groups ) 1382 { 1383 for ( var i = 0; i < groups.length; i++ ) 1384 { 1385 delete this.groups[ groups[ i ] ][ jid ]; 1386 } 1387 1388 for ( var i = 0; i < groups.length; i++ ) 1389 { 1390 var contacts = 0; 1391 for ( var contact in this.groups[ groups[ i ] ] ) 1392 contacts++; 1298 1393 1299 if( groups ) 1300 { 1301 1302 for ( var i = 0; i < groups.length; i++ ) 1303 { 1304 delete this.groups[ groups[ i ] ][ jid ]; 1394 if ( ! contacts ) 1395 delete this.groups[ groups[ i ] ]; 1396 } 1305 1397 } 1306 1307 for ( var i = 0; i < groups.length; i++ ) 1308 { 1309 var contacts = 0; 1310 for ( var contact in this.groups[ groups[ i ] ] ) 1311 contacts++; 1312 1313 if ( ! contacts ) 1314 delete this.groups[ groups[ i ] ]; 1315 } 1398 1399 // Delete Object roster 1400 if( this.roster[jid] ) 1401 delete this.roster[jid]; 1316 1402 } 1317 1318 // Delete Object roster1319 if( this.roster[jid] )1320 delete this.roster[jid];1321 1403 } 1322 1404 … … 1334 1416 this.setPresence = function(fulljid, priority, show, status) 1335 1417 { 1336 var barejid 1337 var resource 1338 var jid_lower 1418 var barejid = Strophe.getBareJidFromJid(fulljid); 1419 var resource = Strophe.getResourceFromJid(fulljid); 1420 var jid_lower = barejid.toLowerCase(); 1339 1421 1340 1422 if( show != 'unavailable')
Note: See TracChangeset
for help on using the changeset viewer.