|
|
|
@ -44,6 +44,7 @@ |
|
|
|
if(!(list[i].jid in $scope.lookupjid)){ |
|
|
|
el = { |
|
|
|
'ajid': list[i].jid, |
|
|
|
'atruename': list[i].rosterview.name, |
|
|
|
'aval': list[i].value, |
|
|
|
'ajiditems': [], |
|
|
|
'tombstone': false, |
|
|
|
@ -65,14 +66,14 @@ |
|
|
|
for(var j = 0; j < $scope.contacts[i].agroupitems.length; j++){ |
|
|
|
if(!$scope.contacts[i].agroupitems[j].tombstone) |
|
|
|
$scope.lookupjid[$scope.contacts[i].agroupitems[j].ajid] = $scope.contacts[i].agroupitems[j]; |
|
|
|
else // Cleanup tombstoned jid
|
|
|
|
$scope.contacts[i].agroupitems.splice(j, 1); } |
|
|
|
else // Cleanup tombstoned jid
|
|
|
|
$scope.contacts[i].agroupitems.splice(j, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
else // Cleanup tombstoned groups
|
|
|
|
$scope.contacts.splice(i, 1); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
$scope.$apply(); |
|
|
|
}; |
|
|
|
|
|
|
|
@ -117,7 +118,7 @@ |
|
|
|
index = locationOf(element, array, comparer); |
|
|
|
array.splice(index, 0, element); |
|
|
|
|
|
|
|
/* Update dictionnary from the appropriate index */ |
|
|
|
/* Update dictionary from the appropriate index */ |
|
|
|
for(var i=index; i<array.length; i++){ |
|
|
|
dico[array[i][key]] = array[i]; |
|
|
|
} |
|
|
|
@ -134,13 +135,10 @@ |
|
|
|
$scope.lookupgroups[oldgroupname].tombstone = true; |
|
|
|
else{ |
|
|
|
$scope.lookupjid[list[0].jid].tombstone = true; |
|
|
|
|
|
|
|
console.log("Tombstone TRUE for " + list[0].jid); |
|
|
|
} |
|
|
|
} |
|
|
|
/* New group is not in the list */ |
|
|
|
if(!(list[0].groupname in $scope.lookupgroups)) { |
|
|
|
console.log("New groupname" + list[0].groupname); |
|
|
|
/* Create group */ |
|
|
|
el = { |
|
|
|
'agroup': list[0].groupname, |
|
|
|
@ -157,12 +155,14 @@ |
|
|
|
&& ($scope.lookupjid[list[0].jid].ajiditems[0].groupname == list[0].groupname)) |
|
|
|
{ |
|
|
|
$scope.lookupjid[list[0].jid].aval = list[0].value; |
|
|
|
$scope.lookupjid[list[0].jid].atruename = list[0].rosterview.name; |
|
|
|
$scope.lookupjid[list[0].jid].ajiditems = list; |
|
|
|
$scope.lookupgroups[list[0].groupname].agroupitems.sort(jidAvalCompare); |
|
|
|
} |
|
|
|
else{ |
|
|
|
el = { |
|
|
|
'ajid': list[0].jid, |
|
|
|
'atruename': list[0].rosterview.name, |
|
|
|
'aval': list[0].value, |
|
|
|
'ajiditems': list, |
|
|
|
'tombstone': false, |
|
|
|
@ -209,11 +209,8 @@ |
|
|
|
}; |
|
|
|
|
|
|
|
this.getContactTitle = function(c){ |
|
|
|
status = c.status || ""; |
|
|
|
ressource = c.ressource || ""; |
|
|
|
title = c.jid; |
|
|
|
if(status != "") title += " - " + status; |
|
|
|
if(ressource != "") title += " - " + ressource; |
|
|
|
title = c.rosterview.name + " - " + c.jid; |
|
|
|
if(c.status) title += " - " + c.status; |
|
|
|
return title; |
|
|
|
}; |
|
|
|
|
|
|
|
@ -309,10 +306,24 @@ var ressourceCompare = function(a, b) { |
|
|
|
}; |
|
|
|
/* Presence + alphabetical comparison */ |
|
|
|
var jidAvalCompare = function(a, b) { |
|
|
|
|
|
|
|
if(a.ajid=="christine.ho@etu.univ-nantes.fr"){ |
|
|
|
console.log("jidAvalCompare"); |
|
|
|
console.log(a.aval); |
|
|
|
console.log(b.ajid); |
|
|
|
console.log(b.aval); |
|
|
|
} |
|
|
|
n = a.aval - b.aval; |
|
|
|
if(n == 0 && a.ajiditems.length > 0){ /* if the array is empty keep the 0 value */ |
|
|
|
n = a.ajiditems[0].rosterview.name.localeCompare(b.ajiditems[0].rosterview.name); |
|
|
|
if(n == 0){ |
|
|
|
n = a.atruename.localeCompare(b.atruename); |
|
|
|
if(a.ajid == "christine.ho@etu.univ-nantes.fr"){ |
|
|
|
console.log("name a "+a.atruename); |
|
|
|
console.log("name b "+b.atruename); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(a.ajid=="christine.ho@etu.univ-nantes.fr") |
|
|
|
console.log(n ? n < 0 ? -1 : 1 : 0); |
|
|
|
return n ? n < 0 ? -1 : 1 : 0; |
|
|
|
}; |
|
|
|
|
|
|
|
|