updateContactList
1 function updateContactList(selectedContacts, newContactListDisplayName) {
2
3 if (connectionObj.forcedLogout) {
4 isDisconnectedForcedLogout();
5 return false;
6 }
7
8 var fullAddresses = "";
9 var contactListFullAddress = getContactListID(curContactList);
10 var uniqueRef="";
11 var curContactListLoc = curContactList;
12
13 for(var i=0; i < chkdContactsArray.length; i++) {
14 fullAddresses += 'contactID='+ chkdContactsArray[i];
15 if(i < (chkdContactsArray.length - 1)) {
16 fullAddresses += '&';
17 }
18 }
19
20 var paramUpdateContactList = 'updateContactListAndContacts='+'&'+fullAddresses+'&userContactListName='+newContactListDisplayName+'&userContactListID='+contactListFullAddress;
21
22 new Ajax.Request(contactListBaseUrl, {
23
24 method : 'post',
25 onSuccess : function(xh) {
26
27 var output = JSON.parse(xh.responseText);
28
29 if (!connectionObj.forcedLogout) {
30 if (isDisconnectedForcedLogout(output)) {
31 return false;
32 }
33 } else {
34 isDisconnectedForcedLogout(output);
35 return false;
36 }
37
38 if (xh.responseText.toLowerCase().indexOf('error') == -1){
39
40 // if contactList displayName has been updated
41 if (newContactListDisplayName != curContactListLoc) {
42
43 uniqueRefContactListGroup = curContactListLoc + '_group';
44 uniqueRefContactListGroupTop = curContactListLoc + '_groupTop';
45
46 uniqueRefContactListGroup = uniqueRefContactListGroup.replace(/\s/, '_');
47 uniqueRefContactListGroupTop = uniqueRefContactListGroupTop.replace(/\s/, '_');
48
49 // removal of all ul tags or all contactLists
50 if ($(uniqueRefContactListGroup)) {
51 $(uniqueRefContactListGroup).parentNode.removeChild($(uniqueRefContactListGroup));
52 }
53 if ($(uniqueRefContactListGroupTop)) {
54 $(uniqueRefContactListGroupTop).parentNode.removeChild($(uniqueRefContactListGroupTop));
55 }
56
57 } else {
58 // if only the members have been edited
59 for (var i = 0; i < getContactsInCurrentContactList().length; i++) {
60
61 uniqueRef = curContactListLoc+'_'+getContactsInCurrentContactList()[i].wcapUser.userID.userId+'_blItem';
62 if ($(uniqueRef)) {
63 $(uniqueRef).parentNode.removeChild($(uniqueRef));
64 }
65 }
66
67 }
68
69 // update the data layer
70 updateContactListData(curContactListLoc, newContactListDisplayName, chkdContactsArray);
71 }
72
73
74 },
75 onFailure : function(xh) {
76 alert("Oops, there's been an error.");
77 },
78 parameters : paramUpdateContactList
79
80 });
81
82 }
Pages : 1